Repository navigation
Description
Summary
On a desktop cold start the app can replace its whole shell with Failed to load projects. and stay there. The sidebar bootstrap is the shell's only read, it retries for about half a second, and once it has failed nothing refetches it except an unrelated realtime invalidation. The window recovers on its own seconds or minutes later, whenever some thread or project event happens to fire, which reads as "bb says I have no projects, then it fixes itself".
Expected: a bootstrap that fails while the server is still warming up retries until the server answers, and the shell never presents a transient startup failure as a terminal state.
Versions and environment
- bb 0.40.0, desktop app, macOS 15.5 (Darwin 25.5.0)
- Source repro built from
mainatad79bbb5ec909524f8f281e62d860c588a86f332, Node 22.22.3 - Local server on the default port, default data dir (
~/.bb), no Connect, no remote host - Not provider specific: this is the app shell, before any agent is involved
Steps to reproduce
Deterministic repro against a running bb (Playwright, no bb code changes). It injects the failure the cold start produces naturally, an unreachable server for a few seconds while the renderer is already up:
const t0 = Date.now();
const log = [];
await page.route('**/api/v1/sidebar-bootstrap*', async (route) => {
const dt = Date.now() - t0;
if (dt < 8000) { log.push(['fail', dt]); await route.abort('connectionrefused'); }
else { log.push(['ok', dt]); await route.continue(); }
});
await page.goto('http://127.0.0.1:38886/', { waitUntil: 'domcontentloaded' });
for (let i = 0; i < 6; i++) {
await page.waitForTimeout(5000);
console.log(Date.now() - t0, (await page.locator('body').innerText()).includes('Failed to load projects'));
}- Run the snippet against a healthy bb server. The server is reachable again after 8s.
- The app shows
Failed to load projects.and never recovers on its own. - Focus,
visibilitychange,pageshowandonlinedo not recover it either (verified: zero further requests).
Did not reproduce with a single failed request: one 503 followed by a healthy server recovers, because a second consumer of the same query key fetches again shortly after mount. The failure needs to outlast the retry budget, which any cold start on a large data dir does.
Expected vs actual
Actual, request log (ms since load) and screen state:
fail 385
fail 655
fail 925 <- last attempt, 540ms of retry budget spent
(no further requests at all)
t= 5452ms "Failed to load projects."
t=10460ms "Failed to load projects."
t=15464ms "Failed to load projects." <- server healthy since 8000ms
t=20469ms "Failed to load projects."
t=25474ms "Failed to load projects."
t=30494ms "Failed to load projects."
Rendered body at that point is the nav chrome plus the error line, no projects,
no threads:
New thread / Extensions / Automations / GitHub / Kanban / Docs / Tasks /
Settings / Remote access / Report a bug
Failed to load projects.
Expected: retries continue while the server is unreachable, and the shell
renders as soon as the server answers.
Evidence
Cause, three parts, all on main at ad79bbb:
- The bootstrap runs on the default read-retry budget: two retries at a fixed 250ms delay, and only for transport errors. Any
HttpError/BbHttpError, so any HTTP status the warming server returns, gets zero retries.bb/apps/app/src/hooks/queries/query-helpers.ts
Lines 10 to 11 in ad79bbb
const TRANSIENT_READ_RETRY_COUNT = 2; export const TRANSIENT_READ_RETRY_DELAY_MS = 250; bb/apps/app/src/hooks/queries/query-helpers.ts
Lines 62 to 93 in ad79bbb
export function isTransientReadError(error: unknown): boolean { if (toRecord(error)?.name === "AbortError") { return true; } if (error instanceof HttpError || error instanceof BbHttpError) { return false; } const record = toRecord(error); if (!record || typeof record.message !== "string") { return false; } const message = normalizeErrorMessage(record.message); return ( message.includes("failed to fetch") || message.includes("load failed") || message.includes("networkerror") ); } export function shouldRetryTransientReadQuery( failureCount: number, error: unknown, ): boolean { if (failureCount >= TRANSIENT_READ_RETRY_COUNT) { return false; } return isTransientReadError(error); } bb/apps/app/src/lib/query-client.ts
Lines 158 to 159 in ad79bbb
retry: shouldRetryTransientReadQuery, retryDelay: TRANSIENT_READ_RETRY_DELAY_MS,
- The query is on the static-cache tier,
staleTime: Infinity, with no retry override.bb/apps/app/src/hooks/queries/sidebar-navigation-query.ts
Lines 34 to 60 in ad79bbb
export function useSidebarNavigation(options?: QueryOptions) { const enabled = options?.enabled ?? true; useEnvironmentListRealtimeSubscription({ enabled }); useHostListRealtimeSubscription({ enabled }); useProjectListRealtimeSubscription({ enabled }); useThreadListRealtimeSubscription({ enabled }); return useQuery<SidebarBootstrapResponse>({ queryKey: sidebarNavigationQueryKey(), queryFn: async ({ signal }) => { const response = await fetchSidebarNavigation(signal); // Bounded and written off the critical path; see the cache module. writeCachedSidebarBootstrap(response); return response; }, enabled, ...REALTIME_OWNED_STATIC_CACHE_QUERY_POLICY, // A full load starts from an empty query cache, so the rail showed its // two-row loading skeleton on every visit until the bootstrap resolved. // Replay the last bootstrap this profile received instead (a bounded // copy: projects whole, thread lists capped); the live response replaces // it in place. Consumers treat the replay like any sidebar data // (navigation only), and a cold profile still shows the skeleton, so // first-run behavior is unchanged. placeholderData: () => readCachedSidebarBootstrap() ?? undefined, }); } bb/apps/app/src/hooks/queries/query-policies.ts
Lines 62 to 64 in ad79bbb
export const REALTIME_OWNED_STATIC_CACHE_QUERY_POLICY = { staleTime: Infinity, } as const;
- The failure is terminal in the UI, and the usual escape hatches are closed: focus and reconnect refetches are gated off while the socket is connected, and the error screen has no retry affordance. Only a realtime invalidation of the sidebar key brings the app back.
bb/apps/app/src/views/RootComposeView.tsx
Lines 1908 to 1920 in ad79bbb
// The composer renders immediately with loading pickers; only a failed // bootstrap with no projects at all replaces it (see B28). While the // bootstrap is in flight the project picker shows a loading label and the // projectId-dependent queries inside NewThreadComposer stay disabled. if (!projects && sidebarNavigationError) { return ( <PageShell contentClassName="min-h-full items-center justify-center"> <p className="py-12 text-center text-sm text-destructive"> Failed to load projects. </p> </PageShell> ); } Lines 31 to 38 in ad79bbb
const queryClient = createAppQueryClient({ // While the realtime socket is connected, change events and the reconnect // watermark own cache freshness; a focus or browser-online refetch on top // would re-request every active query on each phone unlock, app switch, // and mobile-Safari `online` blip. shouldRefetchOnWindowFocus: () => wsManager.getConnectionState() !== "connected",
Why a cold start lands in that window, from ~/.bb/logs/server.1.log on the machine where this was first noticed (data dir at 15 MB bb.db plus a 7.5 MB WAL):
11:58:40.999 Server listening
11:58:42.706 last plugin loaded (+1.7s)
11:58:47.025 [plugin:github] synced 240 item(s) across 3 repo(s) (+6.0s)
The desktop probe only waits for /api/v1/system/config, so the renderer can issue its bootstrap during that warm-up. Numbers above are wall clock from the log lines; the request timings are Date.now() deltas inside the interceptor.
What you ruled out
- Not a duplicate of [desktop] "Could not start bb" most of the time #2480: that one is the pre-window launcher probe reporting "Could not start bb". This one is after the window loads and the shell is up.
- Not sidebar-bootstrap ships 138KB and refetches wholesale on thread status changes #1302 or Reload flashes: Tasks empty state, plugin route chrome, composer model and reasoning #1676: those are bootstrap payload size and reload flashes, not a failed bootstrap left terminal.
- Not data loss: the projects are in the database the whole time,
curl http://127.0.0.1:38886/api/v1/sidebar-bootstrapreturns them in 9ms while the window shows the error. - Not focus related: focus, visibility, pageshow and online events produce zero refetches in this state, by design (
shouldRefetchOnWindowFocusis gated on the socket being disconnected).
Suggested fix
Give the app shell's bootstrap its own retry policy instead of the generic read budget: treat a warming server (5xx, 408, 429) as retryable alongside transport failures, and back off exponentially to a 4s cap over six retries, about twelve seconds of coverage.
Patch, tests, and end-to-end verification: mariomile/bb@main...mariomile:bb:fix/sidebar-bootstrap-startup-retry
Verified with the repro above against the patched app: attempts at 821, 824, 1082, 1585, 2591, 4600ms, success at 8603ms, and the shell renders projects without ever showing the error. Unit and hook tests added; the hook test fails on main and passes with the change. tsc --noEmit and oxlint clean on the touched files.
Two things deliberately left out, since they are UI changes and CONTRIBUTING asks for an issue first:
- A retry affordance on the error screen. Today a user whose bootstrap fails past the retry window has no way to ask for another attempt, short of reloading the window.
- Refetching a bootstrap that has no data when the realtime socket connects, which would make any future variant of this self-healing regardless of the retry budget.
Happy to open a PR for the retry policy alone, or to include either of the above if you want them in the same change.
Suggested priority and effort
Medium. Hits every user whose server is slow to warm up (large data dir, cold page cache, slow disk), no in-app workaround other than reloading the window, no data lost. Effort Low for the retry policy.
AGENT GENERATED
Investigation thread (local bb): thr_xa2mu3c56k, project proj_personal.
Activity
SawyerHood commentedon Aug 27, 2026
Reproduction & root-cause report: https://get-bb.github.io/reports/issues/2533.html
The report has copy-paste repro steps, screenshots where the bug is visual, code permalinks at the base commit, and repro artifacts. It was independently re-run by a second agent (see its Verification section).