Skip to content

Commit 80ce297

Browse files
fix(server): register the bootstrap fiber before it can outlive the caller
Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent facf30f commit 80ce297

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

‎apps/server/src/ws.ts‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,14 +1633,22 @@ const makeWsRpcLayer = (
16331633
// through the tracker.
16341634
const runBootstrap = tracked
16351635
? Effect.gen(function* () {
1636-
const fiber = yield* Effect.forkDetach(settledBootstrapProgram);
1637-
yield* worktreeSetupTracker.begin({
1638-
threadId,
1639-
branch: bootstrap?.prepareWorktree?.branch ?? null,
1640-
baseRef: bootstrap?.prepareWorktree?.baseBranch ?? null,
1641-
stages: ["fetch", "checkout", "submodules", "setup-script", "agent"],
1642-
fiber,
1643-
});
1636+
// Fork and register as one step: a detached fiber keeps going
1637+
// if the caller is interrupted, so it must never exist without
1638+
// the tracker entry that cancel and the stage updates key on.
1639+
const fiber = yield* Effect.uninterruptible(
1640+
Effect.gen(function* () {
1641+
const fiber = yield* Effect.forkDetach(settledBootstrapProgram);
1642+
yield* worktreeSetupTracker.begin({
1643+
threadId,
1644+
branch: bootstrap?.prepareWorktree?.branch ?? null,
1645+
baseRef: bootstrap?.prepareWorktree?.baseBranch ?? null,
1646+
stages: ["fetch", "checkout", "submodules", "setup-script", "agent"],
1647+
fiber,
1648+
});
1649+
return fiber;
1650+
}),
1651+
);
16441652
return yield* Fiber.join(fiber);
16451653
})
16461654
: settledBootstrapProgram;

0 commit comments

Comments
 (0)