Repository navigation
Closed
Closed
Copy link
Labels
confirmed-reproBug reproduced again from a clean trusted checkout; see linked reporthostHost daemon, process lifecycle, memory, event loopperf
Description
Summary
bb-app server (observed 0.42.1 on macOS) chronically stalls its main event loop (~every 5s, maxDelayMs typically 1.9–2.1s, spikes to 5–6s under load). localhost API callers see undiagnosed fetch failed. Restarting the app did not clear the pattern: within ~40s the server was again ~90%+ CPU with continuous stall logs.
Evidence (redacted)
- Continuous
Event loop stalledlines in server logs (intervalMs: 5000,maxDelayMs~1900–2500). - Process sample: main thread often in
better_sqlite3Statement::JS_getunder timers; RSS hundreds of MB; long uptime before restart made it worse. - Local
bb.dbcan grow large;eventstable dominated by bulky rows (including largecommandExecutionpayloads). - During an incident window, host-daemon logged
fetch failedposting events while/hostslatency was ~2s concurrent with usage-limits traffic. - Stall monitor often reports
slowestWorkas a cheap heartbeat (≪10ms) while the loop is actually delayed ~2s — attributable work is under-reported.
Suspected cause
- Sync SQLite on the server event loop against a large
eventstable. - Retention sweep
completed-event-output-truncation(≈10s) appears to scan/update large JSON blobs without yielding (contrast with sweeps that usesetImmediate). - Instrumentation:
runEventLoopWorkmarking sync bodies withblocksEventLoop: false, so attribution blames heartbeats instead of the sweep.
Scale amplifier (not the core bug)
Heavy agent history / large command outputs and host memory pressure make multi-second stalls more likely, but the missing yield + sync DB work on the event loop is the product bug.
Suggested fixes
- Mark sync sweep bodies as
blocksEventLoop: true(and/or stall-triggered CPU profiles) so operators see the real culprit. - Yield truncation batches; avoid loading full
datauntil needed; shrink batches under load. - Tighten events retention for large command outputs / high-churn rate-limit events.
Impact
First-party and third-party plugins that call the local bb HTTP/SDK API fail spuriously (fetch failed) when the hub is wedged—even when their own logic is correct.
Environment
- macOS, desktop bb.app embedding bb-app server on
127.0.0.1:38886 - Observed bb-app 0.42.1
Metadata
Metadata
Assignees
Labels
confirmed-reproBug reproduced again from a clean trusted checkout; see linked reporthostHost daemon, process lifecycle, memory, event loopperf
Activity
bb-slop-cop commentedon Sep 7, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilothost,perf,confirmed-reproconfirmed-reproSawyerHood commentedon Sep 9, 2026
Tracked as a sub-issue of #1131. The parent now covers the shared scope and links this implementation. This issue retains its distinct evidence and acceptance criteria and remains open until that work is complete.
ymichael commentedon Sep 25, 2026
Fixed by #2920