Expand description
Persistent per-session script VMs, as one owned aggregate, with a crisp two-tier lifetime:
- The VM (
globalThis, compiled plugin bytecode, timers) is the heavy, disposable tier. It is rebuilt on poison (timeout/OOM), on a browser-session swap (relaunch/reconnect under the same name), and dropped under the warm-VM cap when another session needs a slot. varsis the light, durable tier: a string store that lives for the logical session’s whole lifetime. It survives every VM rebuild above — cap eviction drops only the VM, not the session record. The single thingglobalThiscannot give you.
A logical session ends (and its vars are released) only on: an
idle-TTL reap, an explicit SessionTable::remove, or
SessionTable::clear (server shutdown). That is the whole vars
durability contract — no fuzzier than that.
Browser-agnostic by construction: a RunContext carries whatever
browser handles a call has (or None) and the browser epoch is
passed in, so every policy here is unit-testable without a browser.
Structs§
- Browser
Session - One logical session: the (disposable) persistent VM, the (durable)
session-scoped
vars, and the browser generation the live VM was built against. Access is serialized by theAsyncMutexSessionTablehands out — that slot lock IS the per-session execution guard, so the invariant is structural, not a comment. - Session
Table - The set of live sessions plus the retention policy. Cheap to share
(
Arcit); every method takes&self.