Browse Source

Fix bug that interrupts error handling early

master
Sven Slootweg 2 months ago
parent
commit
4f89083282
  1. 28
      index.js

28
index.js

@ -66,20 +66,22 @@ module.exports = function simpleSinkStream(_options) {
return attemptRead();
}).catch(isEndOfStream, (error) => {
/* Don't attempt to do another read, we're done. */
if (!onEndCalled && onEnd != null) {
onEndCalled = true;
return Promise.try(() => {
return onEnd();
}).then((result) => {
if (result !== undefined) {
resultBuffer.push(result);
}
return Promise.try(() => {
if (!onEndCalled && onEnd != null) {
onEndCalled = true;
return Promise.try(() => {
return onEnd();
}).then((result) => {
if (result !== undefined) {
resultBuffer.push(result);
}
});
}
}).then(() => {
return resultBuffer.maybeRead(() => {
throw error;
});
}
return resultBuffer.maybeRead(() => {
throw error;
});
}).catch((error) => !isAborted(error), (error) => {
return Promise.try(() => {

Loading…
Cancel
Save