Resolve subscription.close() once streams have been flushed.
See original GitHub issueAfter 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
- OS: OSX
- Node.js version: 8.6.0
- npm version: 5.3.0
- @google-cloud/pubsub version: 0.16.2
Steps to reproduce
- Open a subscription
- Close a subscription with no callback.
- 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:
- Created 6 years ago
- Comments:11 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.@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.