Repository navigation
fix: wait for the server to start before requesting settings - #1511
Merged
Merged
Conversation
Settings rejects every apikey with 401 until the server has started, so it was excluded from the 401 logout. That left a rejected apikey stuck on the boot spinner. Only request settings once Init/Status reports Started, which makes the exclusion unnecessary.
AuthenticatedRoute rendered its children while Init/Status had not loaded yet, so any page opened by direct url could request data before the server had started. Wait for the state there instead of gating Settings in MainPage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
When the stored apikey is no longer valid (for example, after the server's tokens were deleted), the WebUI stays on the boot spinner forever instead of going to the login page.
#1452 excluded
/api/v3/Settingsfrom the 401 logout insrc/core/axios.ts.Settingsis[InitFriendly]on the server, so it stays reachable while the server is starting, and until startup finishes the server rejects every apikey with 401. Without the exclusion, opening the WebUI or restarting the server would log the user out, even with a valid key.The exclusion has a side effect.
MainPagewaits for a realSettingsresponse before it renders anything else. With a bad key,Settingsis the only request that fails and nothing logs out, so the spinner never goes away.What
Nothing under the authenticated routes is rendered, and
Settingsis not requested, untilInit/StatusreportsStarted. TheSettingsexclusion is removed.AuthenticatedRoutenow waits for the server state instead of rendering its children optimistically while the state is not loaded.StartingandFailedalready show theStatusPage, so no page, including one opened by direct url, can request data before the server has started. While the state is loading, an authenticated user sees the same spinner asMainPage.Routerhas its ownSettingsobserver (for the theme) above the route guard, so it only enables it once the state isStarted.Started, a 401 fromSettingsmeans the key was rejected, so the existing 401 logout handles it like any other endpoint.src/core/axios.tsloses one line. No requests are made from the interceptor.Supersedes #1491
#1491 fixed the same bug a different way, and I think that approach was wrong. It kept the interceptor aware of startup by firing a
GET User/Currentprobe whenever another endpoint returned 401, and logged out only if the probe also returned 401.apikeyCheckPendingonly keeps one probe in flight, so while the server starts (every authenticated call returns 401) or a plugin endpoint keeps returning its own 401, a new probe is sent each time the previous one settles.Settingsreturns 401 while the server is starting and the probe then returns 200 because the server just finished starting, the session is kept but the failedSettingsquery is never retried. The user stays on the spinner.Settingswas still requested before the server had started.Gating the request avoids all three, with a few lines instead of a new mechanism, new tests and an
AGENTS.mdrule change. #1491 can be closed in favour of this PR.Where to look
src/core/router/AuthenticatedRoute.tsx: waits for the server state before rendering.src/core/router/index.tsx: theSettingsquery gate inRouter.src/core/axios.ts: the removedSettingsexclusion.Testing
pnpm tscheckandpnpm testpass, and the pre-commit hooks pass.pnpm buildwas not run./webui/goes to the login page and the stored session is cleared (localStorage.apiSessionisnull). On master it stays on the spinner.StatusPage, then the dashboard, with the session kept. Opening a deep link such as/webui/settings/generalduring startup behaves the same.