Skip to content
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

Merged
merged 5 commits into from
Feb 28, 2019

Conversation

stephenplusplus
Copy link
Contributor

@stephenplusplus stephenplusplus commented Feb 26, 2019

Fixes #602

To Dos

  • Confirm it works
    • npm install stephenplusplus/nodejs-storage#spp--602
  • Tests

@stephenplusplus stephenplusplus added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Feb 26, 2019
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Feb 26, 2019
@codecov
Copy link

codecov bot commented Feb 26, 2019

Codecov Report

Merging #615 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/file.ts 98.64% <100%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d10c120...2254070. Read the comment docs.

@stephenplusplus stephenplusplus removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Feb 27, 2019
@stephenplusplus stephenplusplus added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Feb 27, 2019
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Feb 27, 2019
rawResponseStream.on('end', onComplete).pipe(throughStream, {
end: false
});
rawResponseStream.on('error', onComplete)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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);
Copy link
Contributor Author

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.

@stephenplusplus stephenplusplus merged commit c09f7c2 into googleapis:master Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants