Auth: option to report the persisted user immediately and re-validate it in the background
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 42/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- firebase, typescript
- Domain
- authentication
Research direction
Start by reading AuthImpl.initializeCurrentUser and _initializeWithPersistence, including the reload and popup/redirect initialization paths described in the issue. Define how the opt-in setting changes the order of persistence reporting, reload, and resolver startup, while preserving the stated sign-out behavior for non-network failures. Done means the persisted user is reported first and background revalidation updates or clears it as specified.
Written by the indexing model from the issue text.
Description
Product: Auth (@firebase/auth 1.13.6, firebase 12.11.0), web, installed PWA on Android Chrome.
What happens. On start-up, AuthImpl.initializeCurrentUser calls
reloadAndSetCurrentUserOrClear, which awaits _reloadWithoutSaving (a securetoken refresh when
the stored ID token is over an hour old, then accounts:lookup) before the first
onAuthStateChanged / authStateReady(). On a mobile browser, _initializeWithPersistence also
awaits browserPopupRedirectResolver._initialize first (_shouldInitProactively), which loads the
gapi script and the /__/auth/iframe frame.
On a weak connection (2G/3G, or a signal that neither fails nor succeeds) each of those requests
runs toward its timeout (30 s while navigator.onLine is true). The SDK already keeps the stored
user when the reload fails with auth/network-request-failed, so the wait does not change the
outcome; it only delays it. Because Firestore's FirebaseAuthCredentialsProvider holds its queue
until Auth's first token callback, even cache-only Firestore reads wait for it, so an offline-first
app cannot render cached data until Auth has finished talking to the network.
Measured on a Pixel phone, installed PWA, signed in, weak signal: Auth's first report took
2.4–5.9 s of a 4–9 s start (55–66%). Airplane mode, where every request fails at once, started in
0.4 s.
What we'd like. An opt-in setting (for example initializeAuth(app, { revalidateInBackground: true }))
under which initialisation:
- reports the persisted user as soon as persistence is read;
- runs the reload after the first report: on success it persists and notifies as
reload()does;
on a non-network failure it signs out (so a disabled or revoked account still ends its
session, just after the first screen rather than before it); - starts the proactive popup/redirect iframe without awaiting it.
Servers still verify the ID token on every request, so this changes when the client learns that a
session was revoked, not what the session can reach.
What we do meanwhile. A patch-package patch with exactly these changes to
dist/esm/index-*.js, about 30 lines; happy to share it or open a PR if the shape is welcome.
- 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