Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): keep provider notification consumers alive past startSession #6538

Mergedbtsouth(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/6538/headmerged by juliusmarminge View on GitHub

Showing 6 changed files with 131 additions and 1 deletion (loading 3).

x
0 of 6 viewed, 6 left
58 additions and 0 deletionsapps/server/src/provider/Layers/CodexAdapter.test.tsModified
View file
@@ -32,6 +32,7 @@
import * as Schema from "effect/Schema";
import * as Scope from "effect/Scope";
import * as Stream from "effect/Stream";
+import * as TestClock from "effect/testing/TestClock";
import * as CodexErrors from "effect-codex-app-server/errors";
​
import { ServerConfig } from "../../config.ts";
@@ -1150,6 +1151,63 @@
+​
+ // Production calls startSession from a request fiber that finishes as soon as
+ // the session exists. `Effect.forkChild` made the runtime event consumer a
+ // child of that fiber, and Effect interrupts a fiber's children when it
+ // completes, so the consumer died on return and every event the session
+ // emitted afterwards was dropped. The other tests here start the session from
+ // the test fiber, which never completes, so the consumer survived and the bug
+ // stayed invisible. Starting it in a fiber that finishes reproduces
+ // production.
+ it.effect("keeps consuming runtime events after the startSession fiber completes", () =>
+ Effect.gen(function* () {
+ const adapter = yield* CodexAdapter;
+ const startSessionFiber = yield* adapter
+ .startSession({
+ provider: ProviderDriverKind.make("codex"),
+ threadId: asThreadId("thread-outlives-start"),
+ runtimeMode: "full-access",