Skip to content

[AI Improvement] [Task] Fix no-floating-promises in CLI command helpers (open, trackGA4, throttler, cloudbilling) - #11467

Open
joehan wants to merge 1 commit into
mainfrom
ai-improve-582885853-task-fix-no-floating-promises-in-cl
Open

joehan wants to merge 1 commit into
mainfrom
ai-improve-582885853-task-fix-no-floating-promises-in-cl

Conversation

@joehan

@joehan joehan commented Nov 6, 2026

Copy link
Copy Markdown
Member

Description

Fixes @typescript-eslint/no-floating-promises warnings in CLI command and helper code (b/582885853, parent goal b/565072516):

  • src/command.ts (validateProjectId): Mark fire-and-forget trackGA4("error", ...) with void, matching existing void trackGA4(...) usage across the codebase.
  • src/commands/open.ts & src/commands/hosting-channel-open.ts: Attach .catch((err: unknown) => { logger.debug(\Unable to open URL: ${getErrMsg(err)}`); })toopen(...)instead ofawaiting, so browser spawn failures (e.g., missing xdg-open`) log to debug rather than causing unhandled rejections or failing the command after printing the URL.
  • src/gcp/cloudbilling.ts (openBillingAccount): await opn(url) inside the existing try/catch block so browser spawn failures reach the existing logger.debug handler.
  • src/throttler/throttler.ts (process()): Mark void this.handle(this.nextWaitingTaskIndex()) with an explanatory comment noting that handle() records task success/failure itself and process() is intentionally synchronous to drive concurrency.

Note: src/commands/functions-log.ts:28 (opn(url)) was intentionally left out of this PR to avoid a textual conflict with open PR #8211, which rewrites the same if (options.open) block.

Scenarios Tested

  • Ran npx eslint without --quiet on all 5 modified files: 0 errors, 0 @typescript-eslint/no-floating-promises warnings, and 0 new warnings introduced.
  • Ran npx prettier --check on all 5 modified files, npx tsc --noEmit -p tsconfig.json, npm run build, npm run test:compile, and full-repo npm run lint:quiet.
  • Ran targeted Mocha unit tests (src/throttler/throttler.spec.ts, src/throttler/queue.spec.ts, src/throttler/stack.spec.ts, src/gcp/cloudbilling.spec.ts, src/command.spec.ts): 78 passing, 2 pending, 0 failing.

Sample Commands

firebase open
firebase hosting:channel:open <channelId>

@joehan joehan self-assigned this Nov 6, 2026

@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 introduces changes to handle unhandled promises when opening URLs and executing throttler tasks, including adding void operators, awaiting opn calls, and catching errors with debug logging. The reviewer recommends reusing the existing openInBrowser utility from src/utils.ts instead of calling the external open or opn libraries directly in hosting-channel-open.ts, open.ts, and cloudbilling.ts to maintain consistency and facilitate unit testing.

Comment on lines +59 to +61
open(channel.url).catch((err: unknown) => {
logger.debug(`Unable to open URL: ${getErrMsg(err)}`);
});

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

Instead of importing and calling open directly from the open package, reuse the existing openInBrowser utility from src/utils.ts. This utility is specifically designed to wrap open so that it can be easily stubbed out in unit tests.

Please also update the imports at the top of the file to include openInBrowser from ../utils and remove the direct import of open.

Suggested change
open(channel.url).catch((err: unknown) => {
logger.debug(`Unable to open URL: ${getErrMsg(err)}`);
});
openInBrowser(channel.url).catch((err: unknown) => {
logger.debug("Unable to open URL: " + getErrMsg(err));
});
References
  1. Reuse or extend existing utilities: Check imported modules, the immediate subsystem, and src/utils.ts first; reuse or extend existing helpers rather than writing bespoke inline logic. (link)

Comment thread src/commands/open.ts
Comment on lines +117 to +119
open(url).catch((err: unknown) => {
logger.debug(`Unable to open URL: ${getErrMsg(err)}`);
});

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

Instead of calling open directly, reuse the existing openInBrowser utility from src/utils.ts (which is already imported as utils in this file). This ensures consistency and allows the browser opening behavior to be stubbed out in unit tests.

You can also remove the unused import * as open from "open"; from the top of the file.

Suggested change
open(url).catch((err: unknown) => {
logger.debug(`Unable to open URL: ${getErrMsg(err)}`);
});
utils.openInBrowser(url).catch((err: unknown) => {
logger.debug("Unable to open URL: " + getErrMsg(err));
});
References
  1. Reuse or extend existing utilities: Check imported modules, the immediate subsystem, and src/utils.ts first; reuse or extend existing helpers rather than writing bespoke inline logic. (link)

Comment thread src/gcp/cloudbilling.ts
if (open) {
try {
opn(url);
await opn(url);

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

Instead of calling opn directly, reuse the existing openInBrowser utility from src/utils.ts (which is already imported as utils in this file). This ensures consistency and allows the browser opening behavior to be stubbed out in unit tests.

You can also remove the unused import * as opn from "open"; from the top of the file.

Suggested change
await opn(url);
await utils.openInBrowser(url);
References
  1. Reuse or extend existing utilities: Check imported modules, the immediate subsystem, and src/utils.ts first; reuse or extend existing helpers rather than writing bespoke inline logic. (link)

@joehan
joehan marked this pull request as ready for review November 7, 2026 00:01
@joehan
joehan requested a review from bkendall November 7, 2026 00:01

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant