evilsoft / evilsoft/crocks

Errors thrown in an Async#map don't always become Rejected

Open
#387 12 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.6k
Forks
103
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
If an error is thrown in an `Async#map`, it doesn't always become a `Rejected`.

**To Reproduce**
```js
const { Async } = require('crocks')

Async((rej, res) => res('a'))
.map(() => { throw new Error('bad') })
.fork(err => console.error({ err }), val => console.log({ val }))
```

**Expected behavior**
I would expect an object shaped like `{ err }` to be logged to `console.error`, but instead the error is thrown and logged by itself, and neither of the forked functions are called.

**Additional context**
If you wrap a Promise instead, it works as expected:
```js
Async.fromPromise(() => Promise.resolve('a'))('b')
.map(() => { throw new Error('bad') })
.fork(err => console.error({ err }), val => console.log({ val }))
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.