-
v4.0.1
Stablereleased this
2026-08-22 11:41:54 +00:00 | 3 commits to main since this releaseA single-fix patch release: a call issued on the line after
stdb.connectno
longer raises. No API, option, or protocol-visible behaviour changed. The one
observable difference is that a too-early call's error now arrives on the handle
or callback it already returns instead of raising at the callsite; the outcome
still lands.Bug fixes
-
Frames issued before the socket opens are held
(#113) -
stdb.connectreturns before the websocket handshake completes, so a call on
the next line was too early: it reached extension-websocket's ownLuaSend
guard (websocket.cpp:562), which raises for any state that is not
STATE_CONNECTED, and the caller sawConnection isn't connected- an error
from a native module they never wrote, naming neither this SDK nor readiness.
Every other mistake here explains itself: a missing websocket dependency, a
URL with no scheme, a stale generated module all produce messages that name
the actual problem. Those frames are now held in a per-socket outbox and
flushed, in order, whenEVENT_CONNECTEDarrives. The flush is guarded
because HTML5 delivers that event twice for one socket - once from the
emscriptenonopenhandler, once from the shared update loop. Reproduced
in-engine against a live 2.x server before and after: the old raise also
killed the socket, so the run reconnected and then timed out. Four assertions
indev/test/test_init.luapin the hold, the flush, the order, and the
double-EVENT_CONNECTEDguard.The hold covers that one window and no more. After a drop, the gap until the
replacement socket exists still raises, deliberately:set_sendinstalls a
new holder only whenopen()runs, which is after the reconnect backoff, and
holding that gap would strand the caller whenever no socket ever replaces this
one (reconnect = false, or afterclose()) - worse than a raise. A socket
that dies without ever opening still settles every held call through the same
"connection lost"sweep as any other drop, becausestdb/connection.lua
parks each request inpendingbefore callingsend. TheREADINESSnote in
stdb/init.luanow states that boundary, and says to gate on the
"disconnected"and"socket_error"events rather thandb:state(), which
still reads its pre-drop value inside the very handler being told about the
drop.
Known in this release, filed as
#115: a closed
connection still decodes frames, which resurrects its state, re-persists
credentials and re-emits"connected". Not reachable from a native build's
close path. Fixed in v4.0.2.What's Changed
Full Changelog: v4.0.0...v4.0.1
Use as a Defold library
Add to
game.projectdependencies:https://git.nokopia.com/yuris/spacetimedb-defold/archive/v4.0.1.zip https://github.com/defold/extension-websocket/archive/refs/tags/4.2.4.zipextension-websocket is required: Defold does not resolve dependencies
transitively, so without itconnectfails at runtime.Private repo? Append
?token=<access-token>to the URL, the same
shape Defold documents for GitLab. Basic auth in the URL
(https://user:token@...) is not a substitute: the archive endpoint
ignores URL credentials - a real account with a wrong password still
gets200on a public repo - while?token=is validated and a bad
one gets a plain401.Downloads
-
Source code (ZIP)
2 downloads
-
Source code (TAR.GZ)
1 download
-