question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Resolve subscription.close() once streams have been flushed.

See original GitHub issue

After using the pub/sub client for test, I have found that I wanted to know when the queue was flushed before exiting. The comment in the code states that a promise is returned when no callback is provided: https://github.com/googleapis/nodejs-pubsub/blob/master/src/subscription.js#L377 but the code does not return a promise.

Environment details

Steps to reproduce

  1. Open a subscription
  2. Close a subscription with no callback.
  3. Execute .then() on the promise from the subscription close method.

Expected: the callback in the .then() is executed. Actual: Error calling .then on undefined.

I have completed a fix with a test here: https://github.com/STeveShary/nodejs-pubsub/commit/2bf9c33f92bd43f1020f5467c58c48a796348309 . Your contribution guide doesn’t recommend a PR yet, but I can create one quickly.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
callmehiphopcommented, Jan 29, 2018

Ah, I see. In most cases that queue isn’t actually used. Its primary function is to act as a backup in case we’re unable to make a streaming connection. I’d need to investigate a bit more, but it might be possible to implement a flush (or similar) event to listen to.

0reactions
callmehiphopcommented, Mar 12, 2018

@STeveShary we’ve got a fix prepared for this (#92) if you have the bandwidth to test it out that would be fantastic! Otherwise we should have it released within the next day or two.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dart: Do I have to cancel Stream subscriptions and close ...
Short-answer: no, but you should. Nothing in the contract of either StreamSubscription or StreamSink requires closing the resources, ...
Read more >
Streams—The definitive guide - web.dev
The Streams API allows JavaScript to programmatically access ... and never before start() has completed or after flush() has been called.
Read more >
Failed to synchronize cache for repos for RHEL 8
Hi, This issue has not been resolved for me with these commands. I have attempted to remove dnf cache, after creating local repository....
Read more >
Node.js v19.3.0 Documentation
Iterates through the list of functions passed to tracker.calls() and will throw an error for functions that have not been called the expected...
Read more >
"Stream has already been operated upon or closed" Exception ...
Discover how to solve the "Stream has already been operated upon or closed" exception in Java.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found