installations: getId() logs a handled registration failure with console.error; performance: getAuthTokenPromise() leaks it as an unhandled rejection

Open Beginner friendly
#10,526 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
firebase, typescript
Domain
web-dev

Research direction

The files to edit are index.esm.js in @firebase/installations (around lines 871 and 876) and @firebase/performance (around lines 250-256). Remove the .catch(console.error) in installations and add a catch to the getToken().then(...) chain in performance. Done means a blocked registration yields a single rejection to the caller, no console.error, and no unhandled rejection. Run the unit tests for both packages to confirm.

Written by the indexing model from the issue text.

Description

api: installations api: performance bug

Two emitters in the web SDK report a handled network failure as if the app were at fault, which shows up as two browser error events per page load on any client whose network blocks firebaseinstallations.googleapis.com (headless crawlers, locked-down corporate networks), with no fault in the app.

Observed (Datadog RUM, Next.js 16 app, @firebase/installations 0.6.24, @firebase/performance 0.7.14): the POST https://firebaseinstallations.googleapis.com/v1/projects/<id>/installations request is rejected at the client (status_code: 0, TypeError: Failed to fetch). At that instant:

  1. @firebase/installations getId() logs the registration failure with console.error (index.esm.js around lines 871 and 876: registrationPromise.catch(console.error)), although every caller already receives the rejection and handles it. A library should not log a failure it also throws; the host application decides whether it is an error.
  2. @firebase/performance getAuthTokenPromise() calls getToken().then(...) without a catch (index.esm.js around lines 250–256), so the same failure surfaces as an unhandled promise rejection.

Expected: a failed Installations registration is returned to the caller once, as a rejection, and not also logged; Performance handles its own token fetch failure (a breadcrumb or silent disable), so it never produces an unhandled rejection.

Reproduce: load a page that initialises Installations/Performance with firebaseinstallations.googleapis.com blocked (a request-blocking rule in DevTools is enough). Observe one console.error and one unhandled rejection.

Dominant language
TypeScript
Stars
5.2k
Forks
1k
Avg merge
2d 2h
Merged PRs (30d)
77

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from firebase/firebase-js-sdk

All issues in firebase/firebase-js-sdk

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.