Repository navigation
fix: gate cloud bootstrap on authentication #18049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,10 +35,9 @@ const AUTH_WAIT_RETRY_DELAY_MS = 3_000 | |
| * token or a broken auth response can never hang bootstrap forever. | ||
| * | ||
| * Only isInitialized is awaited — onAuthStateChanged fires with null for | ||
| * signed-out users, which sets isInitialized but not isAuthenticated. | ||
| * Awaiting isAuthenticated here would make every signed-out page load wait | ||
| * 35s and fire a false Sentry timeout. The router guard handles the | ||
| * login redirect for unauthenticated users separately. | ||
| * signed-out users, so a signed-out load resolves this wait immediately | ||
| * instead of burning the timeout and firing a false Sentry report. Waiting | ||
| * for an actual user is a separate, unbounded wait in the caller. | ||
| * | ||
| * Retries once after a short delay; if auth is still unresolved, reports it | ||
| * to every observability sink and lets bootstrap continue rather than leaving | ||
|
|
@@ -103,8 +102,16 @@ export const useBootstrapStore = defineStore('bootstrap', () => { | |
| } | ||
|
|
||
| async function startStoreBootstrap() { | ||
| void loadI18n() | ||
|
|
||
| if (isCloud) { | ||
| await bootstrapTracer.settle('auth-gate/initialized', waitForCloudAuth) | ||
|
|
||
| // Signed-out cloud pages (/cloud/login) must issue no authenticated | ||
| // request, so bootstrap parks here until the user signs in rather than | ||
| // loading stores that can only answer 401. | ||
| const { isAuthenticated } = storeToRefs(useAuthStore()) | ||
| await until(isAuthenticated).toBe(true) | ||
|
Comment on lines
108
to
+114
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @christian-byrne FYI I attempted to integrate isAuthenticated check into waitForCloudAuth, but it breaks current assumptions about cloud / core separation in it (where cloud requires auth token but core doesn't). Thought it might be an opportunity that we can simplify this drastically in a separate PR
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tracked as FE-2625. The PR merged with this thread unresolved, so the finding is carried in Linear rather than lost here. Filed automatically; close the ticket if the finding is no longer true at |
||
| } | ||
|
|
||
| const userStore = useUserStore() | ||
|
|
@@ -117,9 +124,7 @@ export const useBootstrapStore = defineStore('bootstrap', () => { | |
| until(needsLogin).toBe(false) | ||
| ) | ||
|
|
||
| void loadI18n() | ||
| const storeLoads = loadAuthenticatedStores() | ||
|
|
||
| void Promise.allSettled(storeLoads).then(() => { | ||
| bootstrapTracer.milestone('stores-ready') | ||
| }) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.