Skip to content

Remote previews return 504 and the host repeatedly reconnects #3407

Open

Description

@amadad

Summary

Remote HTML previews returned HTTP 504: Timed out waiting for command result while the execution host repeatedly reconnected. Provider discovery, workspace requests, and commands for an existing thread also failed during this period. A preview failure should not make the execution host unavailable.

This is an observed production incident on the latest stable release. The suspected cause and a minimal reproduction remain unverified. The investigation report below contains the measured evidence.

Versions and environment

  • BB server and enrolled host package: 0.42.1, also the npm latest version when checked on 2026-09-10.
  • Server: npm installation on an Intel Mac, macOS 26.6.2, Node v26.8.1.
  • Execution host: Ubuntu 24.04, x86_64, 4 vCPU, 7.6 GiB RAM, Node v24.19.0. The generated installer manages its host daemon through user systemd.
  • Private connection: Tailscale Serve HTTPS on port 8443, proxying the server's loopback port 38886. BB Connect is not paired.
  • The server also has a local worker and another enrolled Mac worker.
  • Affected thread: Codex, model gpt-6-astra. The host's installed CLI reports codex-cli 0.154.0; the exact executable version used by that historical session was not separately captured.
  • The thread uses an existing remote workspace, not a managed worktree.
  • Browser/device version was not captured.

Steps to reproduce

These reconstruct the incident workflow. They are not a confirmed minimal reproduction. No artificial network throttling or isolated reproduction has been run.

  1. Run BB on one machine and enroll a Linux execution host through Tailscale Serve.

  2. Use a Codex thread whose workspace is on that execution host.

  3. Create two workspace-relative HTML previews containing embedded slide images. The incident files were 3,352,751 and 2,932,975 bytes.

  4. Display both previews in the thread with these directives:

    ::inline-vis{file="preview-1.html" height="1000"}
    ::inline-vis{file="preview-2.html" height="1000"}
    
  5. During the incident, both previews showed 504 errors. A separate workspace request also failed:

    bb environment status <environment-id> --json

A prior attempt to open a roughly 6 MiB standalone preview preceded the first recorded disconnect. The two smaller inline previews appeared later. The exact initiating request is unknown. The number of open clients or preview remounts was not captured.

Expected vs actual

Expected: previews load or return a bounded file-specific error. Heartbeats, provider discovery, workspace requests, and thread commands remain usable.

Actual messages:

Failed to load iamals-preview-1.html: HTTP 504: Timed out waiting for command result
Failed to load iamals-preview-2.html: HTTP 504: Timed out waiting for command result
Error: HTTP 504: Timed out waiting for command result

The daemon logged:

Server heartbeat acknowledgements stopped; reconnecting
Disconnected from server

The disconnect reason was heartbeat-ack-timeout, code 1013, with leaseTimeoutMs: 30000.

Evidence

Incident window: 2026-09-10, 12:27–13:16 UTC.

  • The Linux daemon journal contained 38 disconnect records with reason:"heartbeat-ack-timeout". The first was at 12:27:18 UTC; the last was at 13:16:26 UTC.
  • The captured server log contained 112 prepareHtmlPreview failures with HTTP 504 and 11 with HTTP 502. These ran from 12:32:39 through 13:16:22 UTC. These are log counts, not counts of distinct user actions.
  • The server logged 49 Failed to resolve provider models records and 166 Failed to resolve installed-only provider status records. All named the affected Linux host.
  • The server logged 194 Daemon heartbeat for inactive session, closing socket records. All named the same host. Records included closeReason:"replaced"; messages from old sessions arrived after replacement.
  • The affected thread had Live ready turn command failed with Host is not connected at 12:38:30.349, 12:49:09.131, and 13:11:14.813 UTC.

These counts come from JSON log parsing and a literal match of the daemon's disconnect reason. No application content or credentials are attached.

Thread: thr_5qgyid4t3r
Environment: env_e4jegb7pay
Host: host_twvvcydq2y

Code observations and suspected cause

The installed inline-vis bundle source map shows prepareHtmlPreview reading the entire file through bb.sdk.files.read. It then checks encoding and size, and returns only { file }.

The same sequence exists in inline-vis/server.ts at 1bc80e1d57991fe60a3896e60e0159427194c7bb. This commit was inspected, not built or used to reproduce the incident.

The installed daemon sends file RPC responses and application heartbeats through the same WebSocket. Large file replies delaying heartbeat traffic are a hypothesis consistent with the delayed session messages. No socket backlog measurement was captured during a failed preview request. This does not establish that previews caused the disconnects.

A useful next test would load these file sizes over a constrained connection while measuring heartbeat delay and small RPC latency. If confirmed, file validation and transfer should preserve control-message responsiveness. This report does not prescribe a timeout increase or a particular transport replacement.

What was ruled out or remains unknown

  • The daemon service did not restart: NRestarts=0 during inspection. It reconnected its socket within the same service run.
  • At inspection, the Linux host had about 3.8 GiB available RAM, no current memory pressure, and 68 GiB free disk. This does not rule out earlier transient pressure.
  • All 22 recorded turn/started events had matching turn/completed records with status completed. The evidence does not show 22 Codex crashes or lost completed turns.
  • The server's local daemon log showed no matching heartbeat reconnect pattern in the captured period.
  • After the last recorded reconnect, the same workspace-status request succeeded. A direct HTTPS preview served by the Linux host returned HTTP 200. This bypasses BB's file path and is only a workaround.
  • Searched open and closed issues for preview timeouts, heartbeat failures, and file backpressure. Remote host can remain connected with a one-way-stale daemon WebSocket #2358 concerns a stale Connect return path; this deployment uses Tailscale Serve and has the later heartbeat-ack mechanism. The underlying cause here is not yet established.
  • No test on a clean BB data directory, another provider, or a current-main runtime was performed.

Suggested priority and effort

High impact in this deployment: preview failures coincided with failures across the execution host's control operations. Direct preview links provide a workaround. No data loss was confirmed. Repair effort is unknown pending reproduction.

Checks

  • The incident occurred on the latest stable release; the lack of an isolated reproduction is stated above.
  • Open and closed issues were searched.
  • The investigation report and source thread identifiers are included above.

AGENT GENERATED

Activity

  1. added theissue type on Sep 10, 2026
  2. added
    host
    remote
    inline-vis
    partial-repro
    on Sep 10, 2026
  3. bb-slop-cop commented on Sep 10, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    Classified Bug · High priority · Medium effort; added host, remote, and inline-vis. No existing classification was replaced.

    Reproduction and root-cause report: PARTIALLY REPRODUCED, medium root-cause confidence; applied partial-repro.

    Two clean checkouts showed that actual daemon file replies at an imposed 64 KiB/s bottleneck blocked application heartbeats until acknowledgement timeout, with about 4 MB queued. Fast controls succeeded; 13 existing connection tests passed. The full preview/HTTP 504 incident and its production cause remain unverified.

    No PR: preserving control responsiveness during bulk transfer needs a transport design decision outside the simple-fix boundary. The report includes the repeatable transport probe and both runs.

    AGENT GENERATED

  4. brsbl commented on Oct 1, 2026

    @brsbl
    Collaborator

    Another occurrence: thread provisioning fails with Timed out waiting for command result

    The same transport stall happened during thread provisioning, with no HTML previews involved. Two threads spawned concurrently into the same Project checkout environment both failed after 51s:

    Preparing workspace
    Preparing Project checkout…
    Using workspace: <project checkout>
    Provisioning thread failed (51s)
    Timed out waiting for command result
    

    Versions: server and enrolled macOS host are both 0.44.1-nightly.36184725653.1. The server runs on a Linux machine. The Mac host connects through BB Connect.

    Timeline (2026-10-01 UTC)

    Time Side Event
    00:32:24 daemon Event delivery stops. At 00:32:54 the log reports Daemon event queue is backing up with queueDepth: 28 and queueAgeMs: 30794.
    00:32:50 server Thread created. environment-project-checkout worker ready at 00:32:51.
    00:33:16 daemon Last acknowledged heartbeat.
    00:33:21 daemon Still receiving server→host RPCs (environment.hook.run). The server→host direction is alive.
    00:33:40 daemon Failed to post daemon events: 504 Gateway Timeout
    00:33:41 server Two simultaneous Could not refresh the branch of a reused environment, host.inspect_git_source, command_timeout, 504. Same environment, one per concurrent thread. Both threads fail at the same moment.
    00:33:46 daemon Server heartbeat acknowledgements stopped; reconnecting, code 1013, heartbeat-ack-timeout
    00:34:29 daemon Reconnected. Later spawns worked.

    Observations

    • Half-open link. Server→host messages kept arriving. Host→server traffic (RPC results, heartbeats, event POSTs) stalled for about 80s. Every host RPC issued in that window timed out.
    • The server was not blocked. Event-loop stalls were 0.5–1.2s, with slow SQLite queries up to about 1.7s. That is not enough to explain a 30s RPC timeout.
    • Concurrent noise, not shown to be causal. design-doctrine logged doctrine harvest: nowhere to publish rules; leaving the thread queued about 4.4k times in a few minutes, roughly 8 per second.
    • Provisioning has no retry for this. The refresh warning is swallowed, but provisioning still ends in a terminal error from the same timeout. A transient stall of the host connection fails the spawn outright instead of waiting for the reconnect at 00:34:29.

    Unverified: what blocked the host→server direction. It could be a large reply queued ahead of control traffic as in the original report, the Connect relay, or the network. The daemon does not log successful RPC sends or socket backlog, so this cannot be determined from these logs.

    Source thread: thr_djpfy477ri

    AGENT GENERATED

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

    hostinline-vispartial-reproremote

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions