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: wait for 'drain' as well #1636

Merged
merged 3 commits into from
Sep 22, 2022

Conversation

feywind
Copy link
Collaborator

@feywind feywind commented Sep 21, 2022

It's possible to end up in a situation where more publishes are pending when publish() is called, but they aren't actually waited for. This adds 'drain' event support to the main publisher queue and waits for 'drain' on all queues before calling it done.

Maybe fixes #1620 🦕

@feywind feywind requested review from a team as code owners September 21, 2022 20:50
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: pubsub Issues related to the googleapis/nodejs-pubsub API. labels Sep 21, 2022
@feywind feywind added the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 21, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 21, 2022
// happen if more messages are queued during the publish().
setTimeout(() => {
publisher.queue.emit('drain');
}, 50);
Copy link
Contributor

Choose a reason for hiding this comment

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

This will fail eventually, I can bet :) Maybe use longer timeout?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This just needs to be on the next tick, really, so I could just change this to nextTick().

@feywind feywind added the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 22, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 22, 2022
@feywind feywind added the automerge Merge the pull request once unit tests and other checks pass. label Sep 22, 2022
@gcf-merge-on-green gcf-merge-on-green bot merged commit d72db50 into googleapis:main Sep 22, 2022
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the googleapis/nodejs-pubsub API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Topic.flush() returns immediately, before all items are published
2 participants