Messaging getToken() rejects with "Installations: Generate Auth Token request failed with error 404 NOT_FOUND" after the FID was deleted server-side, instead of re-registering
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- firebase, typescript
- Domain
- backend-api-design
Research direction
Start with packages/installations/src/helpers/refresh-auth-token.ts and packages/messaging/src/internals/requests.ts, then trace the tests for auth token refresh and Messaging getToken(). Check how a 401 or 404 response removes the local installation and how Messaging handles the resulting rejection. Done means the first getToken() call re-registers and retries once after a 404, with tests covering that flow.
Written by the indexing model from the issue text.
Description
Operating System
Not OS-specific (web SDK code path). Seen in production on Android Chrome (reduced UA reports "Android 10", real version unknown); reproduced on Windows 11 with Chrome.
Environment (if applicable)
Chrome 155 on Android (mobile web, production). Also reproduced on desktop Chrome, Windows 11.
Firebase SDK Version
12.19.0 (@firebase/installations 0.6.24, @firebase/messaging 0.13.3)
Firebase SDK Product(s)
Installations, Messaging
Project Tooling
Angular 22 application built with the Angular CLI application builder (esbuild), TypeScript 6
Detailed Problem Description
The Installations docs state that the backend deletes a Firebase installation ID (FID) after 270 days of inactivity
(https://firebase.google.com/docs/projects/manage-installations). The web SDK keeps the old FID and its auth token in
IndexedDB. When such a user comes back, the first authTokens:generate call returns 404 NOT_FOUND and
getToken(messaging) rejects with:
FirebaseError: Installations: Generate Auth Token request failed with error
"404 NOT_FOUND: Requested entity was not found." (installations/request-failed).
The SDK already knows how to heal: fetchAuthTokenFromServer removes the local entry on 401/404 so the next call
registers a new FID, and the next getToken() indeed succeeds. But the first call still rejects, so every app has to
catch this specific error and retry itself. Nothing is actually wrong at that point, and the error message gives no
hint that it is recoverable.
Where it happens:
packages/installations/src/helpers/refresh-auth-token.ts,fetchAuthTokenFromServer: onserverCode401 or 404
it callsremove(installations.appConfig)and thenthrow e.packages/messaging/src/internals/requests.ts,getHeaders:await installations.getToken()with no catch.
requestGetTokenawaitsgetHeadersbefore itstry, so the rejection bypasses theTOKEN_SUBSCRIBE_FAILED
wrapping and there is no retry (fetchWithExponentialRetryonly wraps the fetch inrequestCreateRegistration).
installations.getId() swallows the same refresh failure (.catch(console.error)), so only the Messaging path
surfaces it to users.
Expected: after a 404 on authTokens:generate, refreshAuthToken (or Messaging's getToken path) re-registers
the installation and retries once, so getToken(messaging) resolves with a token the same way the second call does.
Related earlier reports, closed as stale without a diagnosis: #8007, #7998 (same 404), #7566 (403 variant).
Steps and code to reproduce issue
Any app that calls getToken(messaging) with notification permission granted. To simulate the server-side deletion
without waiting 270 days:
-
Load the app once so IndexedDB
firebase-installations-database/firebase-installations-storeholds a
registered entry. -
In the DevTools console, make the stored FID unknown to the server and force a token refresh, then reload:
const req = indexedDB.open('firebase-installations-database'); req.onsuccess = () => { const tx = req.result.transaction('firebase-installations-store', 'readwrite'); const store = tx.objectStore('firebase-installations-store'); store.openCursor().onsuccess = e => { const cursor = e.target.result; if (!cursor) return; const entry = cursor.value; entry.fid = entry.fid.slice(0, -1) + (entry.fid.endsWith('a') ? 'b' : 'a'); // FID the server does not know entry.authToken.creationTime = 0; // force a refresh cursor.update(entry); cursor.continue(); }; tx.oncomplete = () => location.reload(); }; -
Observe:
POST .../installations/<fid>/authTokens:generatereturns 404 andgetToken(messaging)rejects with
installations/request-failed. The IndexedDB entry is gone. -
Reload again: a new FID is registered and
getToken(messaging)resolves.
import { getMessaging, getToken } from 'firebase/messaging';
const messaging = getMessaging(app);
await getToken(messaging, { vapidKey }); // first call after the FID was deleted server-side: rejects
await getToken(messaging, { vapidKey }); // second call: resolves
- Dominant language
- TypeScript
- Stars
- 5.2k
- Forks
- 1k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 77
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from firebase/firebase-js-sdk
-
AI: ChatSession.sendMessage / sendMessageStream throw TypeError on blocked prompts (empty candidates) when tools are setPossibly taken @abhiramshaji-cyber claimed this today. Openapi: firebaseai
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
firebase/firebase-js-sdk#10641 ·
Maintainers usually reply within 1 day
-
api: firestore needs-attention question Repro Needed
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
firebase/firebase-js-sdk#10595 ·
Maintainers usually reply within 1 day
-
api: installations api: performance bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
firebase/firebase-js-sdk#10526 · 3 comments ·
Maintainers usually reply within 1 day
-
@firebase/firestore pins @grpc/grpc-js to ~1.9.0, holding consumers on a flagged releasePossibly taken @cherylEnkidu claimed this 50 days ago. Openapi: firestore needs-attention question stack:Angular
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
firebase/firebase-js-sdk#10400 · 4 comments · 9 reactions · 1 assignee ·
Maintainers usually reply within 1 day
-
Some (sub) package.json do not list the licences which lead to tools like syft report unknown licencePossibly taken @phoekerson claimed this 84 days ago. Openquestion
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
firebase/firebase-js-sdk#9326 · 5 comments ·
Maintainers usually reply within 1 day
All issues in firebase/firebase-js-sdk
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
inabagumi/shinju-date#7406 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
umami-software/umami#4787 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day