Token persistence via sys.save #6
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#6
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?
Identity/token from InitialConnection should persist across sessions; reuse on next connect via Authorization header.
Closed in
7c0fac9— identity survives an app restartConformance runs the headless client twice; the second run has no token in its environment and must still come back as the same player:
The script fails if the two identities differ, so this cannot silently rot.
What landed
connection.luatakes an injectablestorage = { load, save }and writes through it whenIdentityTokenarrives. Pure and unit tested with a fake table — no engine required.init.luadefaults storage tosys.save/sys.loadviastdb.sys_storage(name), keyed under the app's save directory.opts.token→ persisted token. So a caller can always override, and a reconnect never regresses to a stale stored value.storage = falseopts out entirely for callers who want to own credential handling.Why this matters beyond convenience
Identity is the player in SpacetimeDB — rows keyed by
caller_identityare that player's data. Without persistence every relaunch orphans whatever the player owned. This closes that hole with no login flow and no account system.Bonus observation
Run 2 needed two backoff attempts (1s, then 2s) because the server took longer to come back, which exercised the doubling path end to end for free.
Related: #5 (reconnect, closed) — together these mean a client keeps its identity across both a dropped socket and a full restart.