Jest hangs when publishing to @google-cloud/pubsub in integration test #2098
Unanswered
gonchantech
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have an integration test that publishes a domain event to Google Cloud Pub/Sub (using the Pub/Sub emulator). The test itself passes, but Jest never exits.
If I comment out the publishMessage/dispatch call the test exits fine. Removing subscription listeners does not fix the issue, so the problem seems to be on the publisher side.
What happens
Key snippets (simplified)
EventDispatcher (simplified)
EventDispatcher Test(simplified)
What I have tried
subscription.removeAllListeners()on the subscriber side (not the cause).EventDispatcher.dispatch()I added:await pubSubClient.topic(topicName).flush(); await Promise.allSettled(publishPromises); await pubSubClient.close();and did not made the hang go away.
dispatch/publishMessagecall: problem disappears.Notes
Question
How can I solve this issue ?
Doesn't await publishMessage wait until the publish is actually successful?
Beta Was this translation helpful? Give feedback.
All reactions