@devries-cameron20 / t3code Mirror · read-only / commits / 33773ff17e
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 25, 07:30 UTC

Harden Claude stream exit handling (#1504)

Julius Marminge committed Mar 28, 2026 at 16:13 UTC 33773ff17eb7dcdb3a020b0d0a1c27ac0df86125
1 file changed +15 -6
apps/server/src/provider/Layers/ClaudeAdapter.ts
+15 -6
@@ -2817,16 +2817,25 @@ const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
2817 providerRefs: {},
2818 });
2819
2820 - const streamFiber = runFork(runSdkStream(context));
2820 + let streamFiber: Fiber.Fiber<void, never>;
2821 + streamFiber = runFork(
2822 + Effect.exit(runSdkStream(context)).pipe(
2823 + Effect.flatMap((exit) => {
2824 + if (context.stopped) {
2825 + return Effect.void;
2826 + }
2827 + if (context.streamFiber === streamFiber) {
2828 + context.streamFiber = undefined;
2829 + }
2830 + return handleStreamExit(context, exit);
2831 + }),
2832 + ),
2833 + );
2834 context.streamFiber = streamFiber;
2822 - streamFiber.addObserver((exit) => {
2823 - if (context.stopped) {
2824 - return;
2825 - }
2835 + streamFiber.addObserver(() => {
2836 if (context.streamFiber === streamFiber) {
2837 context.streamFiber = undefined;
2838 }
2829 - runFork(handleStreamExit(context, exit));
2839 });
2840
2841 return {