Repository navigation
Description
Summary
Every enrolled host daemon drops its connection to the bb server at the same second, several times an hour, because the server event loop stalls past the 30s heartbeat lease. The connect tunnel then closes and session reopen returns 502/503/504. This is not a single machine's network.
Versions and environment
- bb 0.46.1 on the server and on every enrolled host (latest release at the time of writing is desktop 0.48.0; not yet rolled here)
- Server: Linux,
bb-app.serviceup since 2026-10-22, process never crashed - Hosts: two macOS (arm64), one Linux, plus the server host's own daemon. Daemons were started on different days (26 Oct, 28 Oct 18:46 UTC, 28 Oct 20:47 UTC) and still dropped together
- Connect URL:
https://automancer.getbb.app(tunnelwss://automancer.getbb.app/__tunnel, originhttp://127.0.0.1:38886) - Host daemon lease:
leaseTimeoutMs30000
What happens
On 2026-10-28 the three remote host daemons logged 99, 100 and 43 Disconnected from server events. 77 timestamps match between the two busiest hosts to the exact second; 26 timestamps match all three hosts exactly, including 2026-10-28 23:14:11 UTC.
Client-side sequence, same on every host:
Server heartbeat acknowledgements stopped; reconnecting(leaseTimeoutMs30000)Disconnected from serverwith code 1013heartbeat-ack-timeout, code 1006, code 1001tunnel disconnected, or code 1000Failed to open session: 502 Bad Gateway/503/504 Gateway TimeoutConnected to servera few seconds later
One client entry names the edge explicitly: code 1000, reason CloudFlare WebSocket proxy restarting.
Disconnect reasons on the busiest host that day: code 1000 (empty) x45, 1013 heartbeat-ack-timeout x39, 1006 x9, 1001 tunnel disconnected x6, 1000 CloudFlare WebSocket proxy restarting x1. Failed to open session that day: 504 x22, 503 x19, 502 x4.
The daemons themselves stayed up (KeepAlive, runs=1, never exited). Disconnects are reconnects, not daemon crashes. Several drops happened while host plugin workers were idle, so this is not head-of-line blocking from a bulk file reply.
Server side, same seconds
~/.bb/logs/server.*.log on the origin, ±60s:
18:11:15 UTC (server.9.log): Event loop stalled with maxDelayMs 14,311 / 9,471 / 14,529. At 18:11:21 [plugin:connect] event loop stalled for 32s; restarting the tunnel heartbeat deadline, then at 18:11:25 tunnel closed (code 1006) with lastHeartbeatAckAgeMs 32,826, and every daemon WebSocket closed. Tunnel reconnected at 18:11:44 (upgradeMs 4,363). read ECONNRESET on an origin GET. Daemon WebSockets reopened at 18:12:08.
21:29:04 UTC (server.10.log): stalls of 16s, 26s, 22s, 16s. At 21:28:58 event loop stalled for 26s. Daemon WebSockets closed and reopened together. At 21:29:57 four level-50 Timed out waiting for command result plus read ECONNRESET on GET /api/v1/sidebar-bootstrap.
23:14:11 UTC: milder stalls (0.7–2.4s) and Thread timeline build blocked the event loop (1,768ms at 23:12:43). At 23:14:10 tunnel closed (code 1006), lastHeartbeatAckAgeMs 4,986 — one second before every client logged code 1001 tunnel disconnected. Tunnel connected again at 23:14:12.
The server process never restarted. It stalled, dropped the tunnel, and recovered. bb machine list still showed every host connected after each reconnect, which hides the gaps.
Expected vs actual
Expected: a host daemon holds its server websocket for hours. A server stall shorter than the lease does not drop every machine.
Actual: stalls of 14–32s blow the 30s lease, the Cloudflare tunnel closes, and every host daemon disconnects and then fails to reopen the session with 502/504 until the tunnel is back.
Related
- Remote previews return 504 and the host repeatedly reconnects #3407 (host repeatedly reconnects, 504). That repro was head-of-line blocking during a bulk transfer. These drops also happen with idle plugin workers, and the server log names an event-loop stall, not a large queued reply.
- Terminal typing waits a full network round trip per key and freezes during server event-loop stalls #5634 (event-loop stalls freeze the server). Same stall class; this report is the host-daemon disconnect that follows.
- Tolerate event-loop starvation in the connect tunnel heartbeat #2718 (closed) tried to tolerate event-loop starvation in the connect tunnel heartbeat. On 0.46.1 a 26–32s stall still closes the tunnel (
restarting the tunnel heartbeat deadline, then code 1006). - Connect: threads slow to open, frequent "bb connect hit a temporary problem" #6450 is the user-visible "bb connect hit a temporary problem" during the same windows.
Suggestion
Keep the connect tunnel and host-daemon lease alive across an event-loop stall longer than 30s, or raise the lease and heartbeat deadline together so a 30s stall is not a full reconnect storm. A timeline build or other server work should not be able to close every machine websocket.
Happy to retest on 0.48.0 if a build after 0.46.1 already changes this. I have not upgraded the production server as part of this report.
Activity
bb-slop-cop commentedon Oct 29, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilothost,connect,perf,partial-repro.ServerConnectionobjects all request reconnect at simulated 35 seconds during a 32-second acknowledgement blackout. Tunnel-local stall grace does not renew remote host leases.Read thread todos, commands, and options without building a timeline …
Read thread head state without building a timeline window (#7238)
Acknowledge daemon heartbeats without touching SQLite (#7760)