Skip to content
This repository was archived by the owner on Mar 17, 2026. It is now read-only.

fix: wait for 'drain' as well#1636

Merged
gcf-merge-on-green[bot] merged 3 commits intogoogleapis:mainfrom
feywind:gh1620-topic-flush
Sep 22, 2022
Merged

fix: wait for 'drain' as well#1636
gcf-merge-on-green[bot] merged 3 commits intogoogleapis:mainfrom
feywind:gh1620-topic-flush

Conversation

@feywind
Copy link
Copy Markdown
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 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
Comment thread test/publisher/index.ts Outdated
// happen if more messages are queued during the publish().
setTimeout(() => {
publisher.queue.emit('drain');
}, 50);
Copy link
Copy Markdown
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
Copy Markdown
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

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