HTML5: token durability inside the IDBFS flush window #20
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#20
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
#17 proved identity survives a page reload on HTML5. It did not prove the token is durable immediately after
sys.savereturns, and there is a specific reason to expect it is not.The gap
On HTML5,
sys.savewrites to Emscripten's IDBFS: an in-memory filesystem that flushes to IndexedDB asynchronously. The bytes are in memory whensys.savereturns; they reach IndexedDB some time later.The harness in #17 reloads roughly 15 seconds after the save, so it demonstrates the flush happens — not that it is prompt. The untested window is a player who closes the tab, or navigates away, in the second or so between first connect and the flush. They come back as a brand-new identity, having lost whatever the game associated with the old one.
The failure mode is the nasty one this SDK has hit twice before (#8's dropped
Authorizationheader, #17's negative control): nothing errors. A fresh anonymous identity connects perfectly happily, so the player is silently someone else and no log line anywhere says why.Work
sys.saveon HTML5 already callsFS.syncfs, or whether it only writes to the MEMFS layer. This decides whether there is anything to fix at all — check the engine'ssys.saveimplementation for the HTML5 target rather than inferring from behaviourhtml5.run("FS.syncfs(false, function(){})")behindM.is_html5(), instdb.sys_storage'ssavelocalStorageon HTML5, which is synchronous and needs no flush — but changes where the token lives, so it must be a deliberate decision rather than a side effectdev/tools/html5-conformance.mjsto reload immediately onSMOKE: identity, rather than waiting for the full phase sequence, so the harness actually covers the narrow windowAcceptance
The harness reloads within a few hundred milliseconds of the identity being saved and still recovers the same identity. If Defold already syncs and this turns out to be a non-issue, close it with the engine source that proves so — the README currently warns about a caveat, and an unnecessary warning should be deleted rather than left to spook people.
Priority
Low. It needs a real player closing a tab inside a one-second window on their very first connect, and the cost is one lost anonymous identity, not corruption. Worth doing before anyone ships a game where identity carries progress; not worth blocking anything on.
Documented meanwhile in the README's identity-persistence section, which states the limit instead of claiming durability nobody measured.