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

refactor(deps): Remove get-stream in favor of async iterators #1925

Merged
merged 4 commits into from
May 16, 2022

Conversation

ddelgrosso1
Copy link
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #1909 🦕

@ddelgrosso1 ddelgrosso1 requested review from a team as code owners May 12, 2022 18:10
@product-auto-label product-auto-label bot added size: s Pull request size is small. api: storage Issues related to the googleapis/nodejs-storage API. labels May 12, 2022
@ddelgrosso1 ddelgrosso1 added the owlbot:run Add this label to trigger the Owlbot post processor. label May 12, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 12, 2022
@ddelgrosso1 ddelgrosso1 added the owlbot:run Add this label to trigger the Owlbot post processor. label May 12, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 12, 2022
src/file.ts Outdated
@@ -4104,6 +4102,18 @@ class File extends ServiceObject<File> {
this.storage.retryOptions.autoRetry = false;
}
}

private async getBufferFromReadable(readable: Readable): Promise<Buffer> {
readable.once('error', e => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be some difference in how node < 16 handles errors with streams / async iterators. Test cases were failing with Node 12 / 14 until I explicitly handled a stream error. However, node 16 handled it with just the iterator.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Broke other things... investigating a better way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, this block handled the error a bit differently - the throw wouldn't populate in getBufferFromReadable, but would have a separate context as it is in a callback.

I actually don't think the catch is necessary - for await (const chunk of readable) { should populate the throw. E.g. https://nodejs.org/api/stream.html#readablesymbolasynciterator

@ddelgrosso1 ddelgrosso1 added the owlbot:run Add this label to trigger the Owlbot post processor. label May 12, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 12, 2022
@ddelgrosso1 ddelgrosso1 added the owlbot:run Add this label to trigger the Owlbot post processor. label May 12, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/nodejs-storage API. size: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor(deps): Remove get-stream dependency
2 participants