Skip to content

chore(pubsub): revert port types to reflect numbers and strings - #9549

Merged
shivanee-p merged 2 commits into
mainfrom
revert-9539-fix/pubsub-client-config-port
Oct 6, 2026
Merged

shivanee-p merged 2 commits into
mainfrom
revert-9539-fix/pubsub-client-config-port

Conversation

@shivanee-p

@shivanee-p shivanee-p commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Reverts PR #9539 as to not break customers.

The port type definition was expanded in PR#3542 as a non-breaking change.

@product-auto-label product-auto-label Bot added the api: pubsub Issues related to the Pub/Sub API. label Oct 6, 2026
@shivanee-p
shivanee-p marked this pull request as ready for review October 6, 2026 23:02
@shivanee-p
shivanee-p requested a review from a team as a code owner October 6, 2026 23:02

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request updates the port type in ClientConfig to accept both strings and numbers, refactors promise handling, and formats several type definitions. The review feedback correctly identifies a potential issue in the promise chain of closeAllClients_ where a synchronous error thrown by definedCallback(null) would trigger the .catch block, causing the callback to be executed twice. It suggests using the two-argument form of .then() to prevent this.

Comment thread handwritten/pubsub/src/pubsub.ts Outdated
Comment on lines 392 to 395
.then(() => {
definedCallback(null);
})
.catch(definedCallback);

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.

medium

If definedCallback(null) throws a synchronous error, the promise chain will catch it and invoke definedCallback a second time with the thrown error as the argument. This violates the callback contract (calling it twice) and can lead to unexpected behavior. Using the two-argument form of .then() (similar to the change made in getClient_) ensures that errors thrown inside the success callback do not trigger the error callback.

Suggested change
.then(() => {
definedCallback(null);
})
.catch(definedCallback);
.then(
() => {
definedCallback(null);
},
definedCallback
)
References
  1. Do not wrap callback executions in try-catch blocks to handle synchronous errors without an idempotency guard, as this can cause the callback to be called multiple times if the callback itself throws an error.

@quirogas
quirogas enabled auto-merge (squash) October 6, 2026 23:02
@github-actions
github-actions Bot requested a review from danieljbruce October 6, 2026 23:05
@shivanee-p
shivanee-p disabled auto-merge October 6, 2026 23:07
@quirogas quirogas changed the title fix(pubsub): revert port types to reflect numbers and strings chore(pubsub): revert port types to reflect numbers and strings Oct 6, 2026
@shivanee-p
shivanee-p enabled auto-merge (squash) October 6, 2026 23:19
@shivanee-p
shivanee-p merged commit d62a64f into main Oct 6, 2026
46 checks passed
@shivanee-p
shivanee-p deleted the revert-9539-fix/pubsub-client-config-port branch October 6, 2026 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: pubsub Issues related to the Pub/Sub API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants