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: remove async from final function which causes double invocation … #2094

Merged
merged 2 commits into from Oct 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/file.ts
Expand Up @@ -1530,12 +1530,15 @@ class File extends ServiceObject<File> {
}

const handoffStream = new PassThrough({
final: async cb => {
final: cb => {
// Preserving `onComplete`'s ability to
// destroy `throughStream` before pipeline
// attempts to.
await onComplete(null);
cb();
onComplete(null)
.then(() => {
cb();
})
.catch(cb);
Comment on lines +1538 to +1541
Copy link

Choose a reason for hiding this comment

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

couldn't this cause a double invocation if cb throws?

I think I would have used something such as:

.then(
  () => cb(),
  () => cb()
)

Also I'm not entirely sure how the previous code would end up with a double invocation, but I may miss some context.

},
});

Expand Down