You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
End a request's sandbox fibers before its database connection closes (#1799)
executeWithPause forks the sandbox as a daemon so a pause can outlive the
caller that observed it. That fiber closes over the executor, and the FumaDB
client captures its handle at construction rather than resolving it per
operation, so the fiber keeps a live reference to the connection the host
opened for the scope that built the engine.
On the HTTP executor plane that scope is the request, and its finalizer closes
the pool as soon as the response is written. A sandbox still parked at that
moment issues its next query against a closed pool.
Add ExecutionEngine.shutdown, which interrupts the engine's in-flight sandbox
fibers and waits for them to unwind, and run it from the shared execution-stack
middleware so it happens before the request scope tears the connection down.
Nothing is lost by ending it there: on a per-request engine the pause is
already unreachable once the response is written, since a resume lands on a
different engine and replays the call. The MCP session Durable Object does not
use this middleware and keeps its session-lifetime pauses.
shutdown is a required member so a decorator that rebuilds the engine object
cannot drop it silently.
// Nothing is ever forked here — the platform branch cannot execute — so there
338
+
// is no sandbox fiber to end.
339
+
shutdown: Effect.void,
318
340
// oxlint-disable-next-line executor/no-effect-escape-hatch -- boundary: only the MCP tool server reads this, and the MCP plane never serves a platform credential
0 commit comments