fix: session expiry JSON errors, SSE drops, and subpath routing#5
Open
TheGr3atJosh wants to merge 1 commit into
Open
fix: session expiry JSON errors, SSE drops, and subpath routing#5TheGr3atJosh wants to merge 1 commit into
TheGr3atJosh wants to merge 1 commit into
Conversation
Bug 1 — session expiry caused JSON.parse errors on API fetch calls:
- decorators.py: return 401 JSON for /api/* routes instead of an HTML redirect
- dashboard.js: check resp.status === 401 before calling resp.json(); reload on expiry
Bug 2 — SSE connection closed unexpectedly after idle periods:
- Dockerfile: raise gunicorn --timeout from 180s to 600s; cold Chromium/WeasyPrint
renders after 2-3 min idle were breaching the per-connection deadline
- routes.py: catch BaseException (not just Exception) in render thread so crashes
always emit a done event; reduce SSE heartbeat interval 90s → 15s for proxies
- dashboard.js: add _renderDone guard to prevent onerror/done races; when SSE drops
mid-render (CONNECTING state) fall back to polling /api/render/{id}/pdf every 3s
instead of immediately surfacing a connection-lost error
Bug 3 — all API calls 404 under APPLICATION_ROOT subpath:
- base.html: inject window.APP_ROOT from Flask's request.script_root
- dashboard.js: define _apiBase = (APP_ROOT || "") + "/dashboard" and replace all
eight hardcoded /dashboard/api/... fetch URLs with the prefixed base
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
|
I think the SSE drops are still present but less frequent. I don't fully understand why they are happening. Maybe we convert this to a draft or remove that part of the PR. |
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.
Summary
require_tokennow returns a JSON 401 for/api/*routes instead of an HTML redirect, sofetch()callers don't choke onresp.json(). The JS render flow checksresp.status === 401before parsing and reloads on expiry.--timeoutraised from 180 s to 600 s — cold Chromium + WeasyPrint renders after 2–3 min idle were hitting the per-connection deadline. The render thread now catchesBaseExceptionso crashes always emit adoneevent. SSE heartbeat interval reduced 90 s → 15 s for proxy compatibility. A_pollForPdffallback was added: if the SSE drops mid-render the client polls/api/render/{id}/pdfevery 3 s rather than surfacing a false connection-lost error.window.APP_ROOTis injected fromrequest.script_rootso JS fetch calls work correctly underAPPLICATION_ROOT=/ghostbadger.Test plan
APPLICATION_ROOT=/ghostbadger— all API calls should resolve correctly under the subpath🤖 Generated with Claude Code