Problem
When a previously authenticated laptop wakes before network connectivity is fully ready, Garcon redirects the user to /login. Submitting the login form then reports Failed to fetch. Refreshing after connectivity settles restores the existing session.
The Garcon server and Cloudflare tunnel remain healthy throughout; this is a client auth-state bug, not a server outage.
Reproduction
- Log into Garcon and retain the auth token in local storage.
- Load a protected route while
/api requests are temporarily unavailable, such as immediately after laptop wake or by aborting /api/v1/auth/status.
- The service worker supplies the cached app shell.
- Observe redirect to
/login despite the stored token.
- Attempt login while
/api remains unavailable.
Actual: redirect to login followed by raw Failed to fetch.
Expected: preserve the existing token, remain in an indeterminate/reconnecting auth state, and retry validation when connectivity returns.
Root cause
web/src/service-worker.ts intentionally serves a cached app shell for failed navigation requests while passing /api through to the network.
AuthStore.checkAuthStatus() catches a transport failure from /api/v1/auth/status, sets isLoading=false, and leaves user=null.
web/src/routes/+layout.svelte treats that indeterminate state as unauthenticated and redirects to /login.
- Login uses the same unavailable network path, producing
TypeError: Failed to fetch.
- A related broad catch around
getUser() clears the stored token for every exception, including transient network failures. Token invalidation should occur only after an authoritative auth response such as 401/403.
Evidence
During investigation:
- Garcon service remained continuously active with no correlated restart.
- Cloudflare tunnel remained active with no warnings or restart.
- Public
/api/v1/auth/status returned 20/20 HTTP 200 once reachable.
- The behavior follows directly from the cached-shell/API-passthrough and auth redirect paths above.
Acceptance criteria
Problem
When a previously authenticated laptop wakes before network connectivity is fully ready, Garcon redirects the user to
/login. Submitting the login form then reportsFailed to fetch. Refreshing after connectivity settles restores the existing session.The Garcon server and Cloudflare tunnel remain healthy throughout; this is a client auth-state bug, not a server outage.
Reproduction
/apirequests are temporarily unavailable, such as immediately after laptop wake or by aborting/api/v1/auth/status./logindespite the stored token./apiremains unavailable.Actual: redirect to login followed by raw
Failed to fetch.Expected: preserve the existing token, remain in an indeterminate/reconnecting auth state, and retry validation when connectivity returns.
Root cause
web/src/service-worker.tsintentionally serves a cached app shell for failed navigation requests while passing/apithrough to the network.AuthStore.checkAuthStatus()catches a transport failure from/api/v1/auth/status, setsisLoading=false, and leavesuser=null.web/src/routes/+layout.sveltetreats that indeterminate state as unauthenticated and redirects to/login.TypeError: Failed to fetch.getUser()clears the stored token for every exception, including transient network failures. Token invalidation should occur only after an authoritative auth response such as401/403.Evidence
During investigation:
/api/v1/auth/statusreturned 20/20 HTTP 200 once reachable.Acceptance criteria
/login.Failed to fetch.401/403token invalidation.