Repository navigation
Log a failed session exchange instead of reporting a lost connection - #8061
FarhanAliRaza wants to merge 3 commits into
Conversation
A reverse proxy that does not forward /_reflex/session answers the cookie exchange with an error while the WebSocket works. The event loop adds that error to connectErrors, so the connection toast reports that the server cannot be reached at the WebSocket URL. This test fails until the failure is logged instead.
A failed cookie exchange went into connectErrors, which drives the connection toast and banner. The WebSocket still works in that case, so the toast pointed at the wrong cause: "Cannot connect to server ... Check if server is reachable at ws://.../_event". A 403 from the exchange was already logged to the console. Log every other failure the same way, once per streak of failures, and name the route to check. The retry with backoff is unchanged. The success path no longer clears connectErrors, because the exchange no longer adds to it; the socket's connect handler clears them.
[Low impact] The PR appears safe to merge; no actionable issues were found. SummarySession exchange failures now go to the browser console instead of
Reviews (2) · Last reviewed commit: "Test that a success ends a streak of log..." · Reviewed by Greptile |
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/reflex-frontend/tests/state_connection.test.js">
<violation number="1" location="packages/reflex-frontend/tests/state_connection.test.js:330">
P3: The test only covers two consecutive 405s, so it does not prove the log re-arms after a streak ends. Add a successful exchange between failure streaks and assert that a second message is logged.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
The next failure after a successful exchange is logged again. Removing the reset of the failure count on success makes the test fail with one message instead of two.
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
Why
If a reverse proxy does not forward
/_reflex/session, the session cookie exchange fails while the WebSocket works. The failure went intoconnectErrors, so the page showed this toast for as long as the exchange failed:The toast points at the WebSocket, which works, and hides the real cause. I found this while I tested the enforced session default of #7364 with an app behind a proxy that does not route
/_reflex/session.What changed
connectErrors, because the exchange no longer adds to them. The socket's connect handler clears them.How tested
tests/state_connection.test.js. It mounts the event loop, answers two exchanges with a 405, and checks thatconnectErrorsstays empty and thatconsole.errorgets the complete message once. Before the fix,connectErrorsheld both errors.npm run checkinpackages/reflex-frontendpasses: lint, JSDoc types, and 219 tests.Known limits
docs/api-routes/sessions.md. When both PRs are merged, its paragraph about an exchange that keeps failing can mention the console message.Type of change