Skip to content

0.33.0: every Claude Code turn times out (turn/start) — bridge silently drops schema-invalid requests #853

Closed

Description

@amadad

Summary

After updating bb-app 0.0.32 → 0.33.0 (headless Linux server install via npx bb-app@latest), every Claude Code turn fails with:

JSON-RPC request timed out: turn/start

The Claude Code CLI process spawns and initializes fine, then sits idle forever; the bridge never forwards the turn. Rolling back to 0.0.32 (same machine, same DB, same Claude Code version) fully resolves it.

While debugging I found that the bridge silently drops any request that fails schema validation, which converts whatever the underlying mismatch is into an undebuggable 30s timeout instead of a JSON-RPC error. Filing this both as the regression report and as a request to make that failure mode loud.

Environment

  • bb-app: 0.33.0 (broken), 0.0.32 (works) — server install, npx bb-app@<ver> --data-dir ... --server-port ... under a systemd user unit, accessed via browser over Tailscale
  • OS: Ubuntu 24.04, Node v24.16.0
  • Claude Code CLI: 2.1.217 (~/.local/bin/claude)
  • Bundled agent SDK (from the 0.33.0 bridge): 0.3.197
  • Custom skills injected via BB_INHERITED_SKILLS_ROOTS

Symptom detail

  • Server log: Live ready turn command failed / Live thread start command failed, err JSON-RPC request timed out: turn/start (status 502, command_failed, retryable false) — from callHostOnlineRpcWithRetry
  • Host-daemon log: online host RPC failed, type turn.submit, same timeout, thrown from the daemon bundle's RPC timeout handler
  • Affects both resumed threads and brand-new threads (thread.start path fails identically)
  • First turn after the update failed differently (sandbox deps missing — fair enough, bubblewrap/socat weren't installed; installing them fixed that error), after which every turn produced the timeout above

What I ruled out

  • Claude Code CLI is healthy. Reproducing the bridge's exact spawn (same flags incl. --resume of the same session, --plugin-dir, --settings, stream-json in/out) responds with system/init in ~2s and answers turns normally.
  • The control protocol is healthy. Driving the CLI manually: it answers control_request: initialize promptly and replies with a proper error response to unknown control subtypes.
  • The SDK pairing is healthy. A minimal script against @anthropic-ai/[email protected] (the version the 0.33.0 bridge bundles) + CLI 2.1.217, resuming the same session in the same cwd, completes a turn in ~8s.
  • No stuck buffers. With the deadlock live: bridge and CLI both idle in epoll_wait, and ss -xp shows Recv-Q/Send-Q of 0 on all three stdio socketpairs in both directions — each side believes it's the other's turn.
  • The bridge's turn/start handler replies immediately when it executes (queuePromptInputs + sendResult), and requests are dispatched fire-and-forget, so the observed timeout means the request never reached the handler.

The silent drop

packages/agent-runtime/src/claude-code/bridge/bridge.ts (handleLine):

https://github.com/ymichael/bb/blob/339b4fbad04cf4784049d54e6c00354073bab722/packages/agent-runtime/src/claude-code/bridge/bridge.ts#L1589-L1590

const request = decodeClaudeCodeJsonRpcRequest(parsed);
if (!request) return;

decodeClaudeCodeJsonRpcRequest returns null on any zod validation failure, and the bridge drops the line without replying. The daemon then times out with no indication of what was wrong. Same pattern for the no-default switch in handleRequest (unknown methods are also dropped silently).

I didn't manage to pin down which field in my daemon→bridge requests fails validation before I rolled back (custom skills roots and thread state from the pre-0.33.0 DB are the machine-specific suspects), but the schema-drop behavior means any daemon/bridge disagreement — version skew, migration edge case, unexpected thread state — presents as this same opaque timeout.

Suggested fix

  1. In handleLine, when the envelope parses as a request but claudeCodeCommandSchema validation fails, reply with a JSON-RPC error (e.g. -32602) carrying the zod issue summary, and log it — the daemon would then surface the real cause instantly instead of a 30s timeout.
  2. Add a default case in handleRequest returning -32601 for unknown methods.

Happy to provide logs or re-test a fix build — the broken 0.33.0 state is reproducible on this machine (I kept the migrated DB).

Activity

  1. SawyerHood commented on Jul 22, 2026

    @SawyerHood
    Collaborator

    I think I have a fix! One question:
    if you start a thread with full access does it work? I think this might be related to not having bubblewrap installed on you machine.

    Can you try installing it for your distro?

    https://github.com/containers/bubblewrap

    Will also give you a PR to test soon!

  2. SawyerHood commented on Jul 22, 2026

    @SawyerHood
    Collaborator

    Thanks for this — the debugging writeup made it much faster to track down, and you were right that the silent drop is the real problem. #859 has a fix.

    Your analysis was also right that a well-formed turn/start was vanishing before the handler, and there is a specific mechanism for it beyond the if (!request) return:

    Both directions number their outgoing requests with a plain integer counter from 1 — runtime.ts:230 on the daemon side, bridge.ts:298 (toolCallRequestIdCounter) on the bridge side, incremented per forwarded tool call and per permission request. They share one id space. And decodeBridgeJsonRpcResponse accepted an inbound request as a success response, because the response schemas are non-strict (so the extra method/params pass) and result: z.unknown() also matches a missing key. handleLine checks the response branch first, so a request whose id collided with an outstanding tool call or permission request settled that pending promise with garbage and returned before reaching the request decoder.

    That lines up with your forensics: the bytes were consumed off the socketpair (hence Recv-Q/Send-Q 0), the bridge was idle because it thought it had handled a response, and the handler never ran.

    What's in the fix:

    1. Requests and responses are discriminated on method, per the JSON-RPC spec and matching what the daemon side already does. This also covers the pi and acp bridges, which share the decoder and the same counter pattern.
    2. Both of your suggestions: -32602 with the zod issue summary on a params mismatch (logged to stderr, which the runtime captures into provider diagnostics), and -32601 for an unknown method. The known-method list is derived from the schema union so it can't drift.
    3. Your first error — the missing bubblewrap/socat — was a separate regression. Replace permission modes with approval presets #797 migrated readonly and workspace-write defaults to accept-edits, and accept-edits enables the Claude SDK OS sandbox where 0.0.32's readonly mapping did not. The SDK defaults failIfUnavailable to true, so an install that previously defaulted to readonly lost every session on a host without the deps. That now degrades gracefully instead of aborting the session.

    One honest caveat: I can't prove from here that the id collision was your trigger. It needs a turn where a tool call or permission request is outstanding when the daemon sends its next request — plausible with custom skills and permission prompts, but not something I can confirm without your logs. It is the only mechanism I found that reproduces your exact forensics.

    Since you kept the migrated DB and can still reproduce: a re-test on a build of #859 would be very useful. If something still fails, it should now come back as a JSON-RPC error naming the field or method instead of a 30s timeout — which pins the real cause immediately either way. That diagnostic is the part I'd most like to see output from.

  3. amadad commented on Jul 22, 2026

    @amadad
    ContributorAuthor

    Update: this appears healthy so far after upgrading Claude Code from 2.1.217 to 2.1.218.

    A few details/corrections from testing:

    • bubblewrap 0.9.0 and socat 1.8.0 are installed. Installing them fixed the initial missing-sandbox-dependency error, but the later timeout had still reproduced.
    • Before the Claude Code upgrade, Fable 5 with Full Access also failed repeatedly with JSON-RPC request timed out: turn/start, including after restarting bb. So the observed failure was not limited to bb's sandboxed permission mode.
    • I then upgraded Claude Code to 2.1.218 without restarting the still-running bb 0.33.0 service.
    • After that upgrade, a fresh claude-fable-5 Full Access thread passed its first turn, a second turn, and an explicit stop/resume cycle. Normal use also seems okay so far.

    I can't reproduce the Fable failure on 2.1.218 yet. This makes the Claude Code version relevant, although I don't know whether 2.1.218 fixed the underlying mismatch or whether an older persisted session can still trigger it.

    One additional data point: Codex has intermittently produced the analogous JSON-RPC request timed out: thread/resume after bb reaped an idle provider session, under both Full Access and Auto. Retrying later can succeed. That may be separate, but it suggests resume/reconnect handling is worth checking independently of Bubblewrap.

    I still think the proposed JSON-RPC error response for schema-invalid/unknown requests would be valuable: even if the current compatibility issue is resolved, silently dropping a request turns future version skew into an opaque timeout.

    Happy to test the PR/build if useful.

  4. amadad commented on Jul 22, 2026

    @amadad
    ContributorAuthor

    I read through #859. The ID-collision mechanism fits the observed pattern better than the Claude Code upgrade alone:

    • long/tool-heavy threads failed while fresh no-tool probes passed;
    • failures were intermittent and often appeared around continuation/resume;
    • Codex also showed intermittent thread/resume timeouts, which is consistent with the shared decoder path you fixed.

    So I would not treat the successful 2.1.218 test as proof that the underlying issue is gone—it may simply have changed timing or started a clean session.

    Please send a canary/build install command when available. I can retest against the migrated database with a tool/permission request followed by an immediate colliding turn, plus resumed Fable and Codex sessions. Since bubblewrap and socat are now installed here, that test should isolate the bridge fix from the sandbox-dependency regression.

  5. SawyerHood commented on Jul 22, 2026

    @SawyerHood
    Collaborator

    @amadad you can just checkout that PR and run pnpm i and pnpm start

  6. amadad commented on Jul 24, 2026

    @amadad
    ContributorAuthor

    @amadad you can just checkout that PR and run pnpm i and pnpm start

    Working now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions