Calling `src.destroy()` in `src.map(...).stopOnError(ex)` errors with `Cannot write to stream after nil`.
Opened this issue · 0 comments
richardscarrott commented
Calling src.destroy()
in a stopOnError
callback errors with Cannot write to stream after nil
.
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');
});