GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat: add timeout option and graceful shutdown to Subscription.close() by feywind · Pull Request #2068 · googleapis/nodejs-pubsub
This repository was archived by the owner on Oct 21, 2026. It is now read-only.
Conversation
Contributor
Implements a new This provides more control over the shutdown process:
(This is a re-open of #2037 to make it from the main repo.)
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsImplements a new `timeout` option (using `Duration`) for the `Subscription.close()` method. This provides more control over the shutdown process: - If `timeout` is zero, the subscription closes as quickly as possible without nacking buffered messages. - If `timeout` is positive, the subscription attempts to nack any buffered messages (in the lease manager) and waits up to the specified duration for pending acknowledgements and nacks to be sent to the server. - If no timeout is provided, the behavior remains as before (waits indefinitely for pending acks/modacks, no nacking). The core logic is implemented in `Subscriber.close()`. `PubSub.close()` documentation is updated to clarify its scope and recommend using `Subscription.close()` directly for this feature. Includes: - Unit tests for the new timeout behavior in `Subscriber.close()`. - A TypeScript sample (`samples/closeSubscriptionWithTimeout.ts`) demonstrating usage. - Updated JSDoc documentation for relevant methods.
sofisl
previously approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. optional chaining?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is maxExtensionTime a const? How do we know it will be available? If the former, maybe worth uppercasing?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a config option with a default. So it's set by the constructor:
And then if the user passed a value, it overwrites the default.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would highly recommend to add types in all the new code :)
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be dispatch()?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
| const err = e as [unknown, boolean]; | ||
| if (err[1] === false) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
for my own knowledge, how err[1] === true means was timeout? probably adding type for 'e' here will help :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this has to do with implementing the time-limited Promise wait... it's super annoying to make graceful. I'll look again.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Not sure why it didn't give me a separate box for comments on the one above, but check out Sofia's comment on why I did this like I did.
I agree with you on the second one. I'll add an interface.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Can you elaborate here? The only time I tend to omit them is when they're super obvious (like making a class member like Edit: it didn't tag you :) @miguelvelezsa |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I need to look at a few more review comments before merging anything. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…imeout' into feat-close-timeout
|
Warning: This pull request is touching the following templated files:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if ( | ||
| behavior === SubscriberCloseBehaviors.WaitForProcessing && | ||
| !this._inventory.isEmpty | ||
| ) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Was just debugging the WaitForProcessing functionality locally and stumbled upon this check.
@feywind wouldn't this need to be the following? isEmpty seems to be undefined, instead this might have to be a method call?
| if ( | |
| behavior === SubscriberCloseBehaviors.WaitForProcessing && | |
| !this._inventory.isEmpty | |
| ) { | |
| if ( | |
| behavior === SubscriberCloseBehaviors.WaitForProcessing && | |
| !this._inventory.isEmpty() | |
| ) { |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Created #2117 accordingly
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.