Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Fix interactive terminal sessions hanging when the upstream never completes the WebSocket handshake: bound the upgrade fetch with the same 10s timeout the runtime adapter fetch in that file already uses.
- Stop cancelled Share This Mac cursor reconciliation and release video mailbox waits and their timeout tasks promptly, including cancellation before waiter registration, thanks @SebTardif (#114).

## 0.3.1 - 2026-08-28
Expand Down
2 changes: 1 addition & 1 deletion src/worker/runtime-adapter-transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export async function interactiveTerminalFetch(
session.adapter === runtimeAdapterName
? runtimeAdapterFetcher(env, target, fallbackFetcher)
: fallbackFetcher;
return fetcher.fetch(fetchTarget, { headers });
return fetcher.fetch(fetchTarget, { headers, signal: AbortSignal.timeout(10_000) });
}

export async function readRuntimeAdapterResponseBody(response: Response): Promise<unknown> {
Expand Down
28 changes: 28 additions & 0 deletions tests/runtime-adapter-transport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,31 @@ test("runtime adapter response parsing is bounded and preserves non-JSON error t
ResponseBodyLimitError,
);
});

test("terminal upgrades bound the upstream handshake with a timeout", async () => {
const coordinator = recordingFetcher(new Response(null, { status: 200 }));
const fallback = recordingFetcher(new Response(null, { status: 200 }));
const env = {
CRABBOX_COORDINATOR: coordinator.fetcher,
CRABBOX_COORDINATOR_ORIGIN: "https://adapter.example",
} as RuntimeEnv;
const headers = new Headers({ upgrade: "websocket" });

await interactiveTerminalFetch(
env,
{ adapter: "runtime-v1" },
"wss://adapter.example/v1/terminal",
headers,
fallback.fetcher,
);
assert.ok(coordinator.calls[0]?.init?.signal instanceof AbortSignal);

await interactiveTerminalFetch(
env,
{ adapter: null },
"wss://elsewhere.example/v1/terminal",
headers,
fallback.fetcher,
);
assert.ok(fallback.calls[0]?.init?.signal instanceof AbortSignal);
});