fix(stdb): drop frames on a closed connection #116
No reviewers
Labels
No labels
area:defold
area:docs
area:infra
area:protocol
area:testing
kind:bug
kind:chore
phase:breadth
phase:core
phase:hardening
phase:slice
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
yuris/spacetimedb-defold!116
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "yuris/closed-dispatch-guard"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #115.
A connection the consumer closed still decoded frames, and handling one wrote
_stateback to"connected"over"closed", re-persisted credentials to the save slot, re-emittedconnected, and refilled the cache. Reachable on HTML5, whereCloseConnectiongates its whole body onSTATE_CONNECTEDand the unconditional transition isHAVE_WSLAY-only, soclose()during the handshake never closes the socket and the server keeps pushing.Guard at two layers.
connection.dispatchreturns early on a closed connection, which makes_stategenuinely sticky at"closed"— the propertyM.state's own docstring andschedule_reconnect's terminal branch already asserted, and which #113 had to work around with a second conjunct. TheEVENT_MESSAGEbranch ininit.luadrops earlier still, before the queue, the coroutine and the decode: the dispatch guard alone is downstream of the budgeted queue, andclose()cancels the pump without restarting it, so every post-close frame was retained for the life of the page (~4MB per 200k frames withframe_budgetset).With
_statesticky, both #113 send-path guards collapse to that single test, sinceclosingimplies_state == "closed"and the terminal-drop path sets_statewithoutclosing.conn.closewritesconnrather than its argument so the two can never be split across objects.The zombie test now pins the defect rather than its consequence: state stays
"closed", no token or identity recorded, nothing written to storage, no event emitted, and a post-closeEVENT_MESSAGEthat would raise if it reached the decoder. Both guards mutation-checked — removing either fails exactly one assertion. 13 passed, 0 failed.Wiki updated alongside:
db:state()'s terminality is now documented in API-Reference and Usage-Guide.Reviewed by a second agent;
unhandledevents for dropped frames were considered and declined (the tag already means "unknown ordinal").Drop frames on a closed connection (#115)to Drop frames on a closed connection8b94eeae792406a35299Drop frames on a closed connectionto fix(stdb): drop frames on a closed connection