-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: handle errors from file#createReadStream #615
Conversation
Codecov Report
@@ Coverage Diff @@
## master #615 +/- ##
==========================================
+ Coverage 97.92% 97.94% +0.01%
==========================================
Files 9 9
Lines 868 874 +6
Branches 99 99
==========================================
+ Hits 850 856 +6
Misses 9 9
Partials 9 9
Continue to review full report at Codecov.
|
8cb0406
to
4ec9daa
Compare
rawResponseStream.on('end', onComplete).pipe(throughStream, { | ||
end: false | ||
}); | ||
rawResponseStream.on('error', onComplete) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is having 2 error listeners with the same callback intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code above this actually re-assigns what rawResponseStream
is. When we did that, it was to avoid duplicating the event handler assignments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ok, sorry missed that part.
end: false | ||
}); | ||
rawResponseStream.on('error', onComplete) | ||
.on('end', onComplete) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any scenarios where onComplete
could fire multiple times? I sort of wonder if we should be using something like once
to ensure that doesn't happen somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I 'spose anything is possible! I added new code for that, please take a look!
const onComplete = (err: Error|null) => { | ||
if (err) { | ||
onCompleteCalled = true; | ||
throughStream.destroy(err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throughStream.destroy()
seems to be once-ified automatically.
Fixes #602
To Dos
npm install stephenplusplus/nodejs-storage#spp--602