Calling `src.destroy()` in `src.map(...).stopOnError(ex)` errors with `Cannot write to stream after nil`.
Open
- Dominant language
- JavaScript
- Stars
- 3.4k
- Forks
- 145
- PR merge metrics
- No merged PRs in 30d
Description
Calling `src.destroy()` in a `stopOnError` callback errors with `Cannot write to stream after nil`.
```js
const nodeReadableStream = createNodeReadableStream();
const src = _(nodeReadableStream, () => () => nodeReadableStream.destroy());
src
.map((msg) => {
throw new Error('Failed to map msg');
})
.stopOnError((ex) => {
console.log('Error:', ex);
// Destroy the src so the underlying `nodeReadableStream` can clean up db connections etc.
src.destroy(); // Causes 'Cannot write to stream after nil' error
})
.done(() => {
console.log('DONE');
});
```
Example:
https://runkit.com/embed/ntjjhyh6noz3
Contributor guide
Assessment
This issue has not been assessed yet.