Skip to content

Commit 5b7b183

Browse files
authored
refactor(server): resume suspended sessions unconditionally in the fetch entry (#41938)
1 parent a8fc664 commit 5b7b183

1 file changed

Lines changed: 7 additions & 12 deletions

File tree

packages/server/src/fetch.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@ import { isAllowedCorsOrigin } from "./cors"
77
import { createRoutes } from "./routes"
88
import type { ServerOptions } from "./options"
99

10-
export interface BootOptions {
11-
/**
12-
* Resumes execution-journaled Sessions once the application layer boots. Pair with
13-
* `SessionExecution.configured({ suspendOnStart: true })` on runtimes that can die without
14-
* teardown, so turns orphaned by a hard death replay on the next boot.
15-
*/
16-
readonly resumeSuspendedSessions?: boolean
17-
}
18-
1910
/**
2011
* Builds a web-standard fetch handler — `(request: Request) => Promise<Response>` — serving the
2112
* same HttpApi routes as the Node server process without binding a port, owning a listener, or
@@ -32,13 +23,17 @@ export interface BootOptions {
3223
* Auth follows `createRoutes` semantics: `options.password` enforces Basic auth; omitting it
3324
* serves unauthenticated, so an embedder without a password must front the handler with its own
3425
* access control.
26+
*
27+
* Sessions whose execution claim was never released resume once the layer is built, exactly as
28+
* the Node server process does: a runtime that dies without teardown — an evicted Durable
29+
* Object leaves the same durable signature as a killed process — replays orphaned turns on the
30+
* next boot, and the sweep is a no-op when nothing is suspended.
3531
*/
36-
export const make = Effect.fn("ServerFetch.make")(function* (options: ServerOptions = {}, boot: BootOptions = {}) {
32+
export const make = Effect.fn("ServerFetch.make")(function* (options: ServerOptions = {}) {
3733
const context = yield* Layer.build(createRoutes(options, () => []).pipe(Layer.provide(HttpServer.layerServices)))
3834
// Forked so the returned handler is never delayed; resumed drains are already
3935
// logged and durably recorded by the execution layer.
40-
if (boot.resumeSuspendedSessions)
41-
yield* Effect.forkDetach(Context.get(context, SessionRestart.Service).resumeSuspendedSessions)
36+
yield* Effect.forkDetach(Context.get(context, SessionRestart.Service).resumeSuspendedSessions)
4237
return Context.get(context, HttpRouter.HttpRouter)
4338
.asHttpEffect()
4439
.pipe(

0 commit comments

Comments
 (0)