Skip to content

Desktop: an unreachable saved remote server target leaves the app on a dead-end startup error #1494

Closed

Description

@Joesirven

Desktop: an unreachable saved remote server target leaves the app on a dead-end startup error

Workflow

I run the bb server on a Linux host and point the macOS desktop app at it over Tailscale, using Server ▸ Set Server URL… (a custom target, http://<host>.<tailnet>.ts.net:38886). I updated to the latest desktop build on an M1 MacBook Pro and launched the app.

What happened

The window rendered the startup error screen with a raw Electron internal stack trace:

Could not open bb
Error: ERR_FAILED (-2) loading 'http://<host>.<tailnet>.ts.net:38886'
    at rejectAndCleanup (node:electron/js2c/browser_init:2:89743)
    at finishListener (node:electron/js2c/browser_init:2:89905)
    at WebContents.stopLoadingListener (node:electron/js2c/browser_init:2:90292)
    at WebContents.emit (node:events:521:24)
Logs are under /Users/<me>/.bb/logs/.

The screen has no controls. Recovery is only via the Window ▸ Server menu, which the screen does not mention, or by hand-editing ~/Library/Application Support/bb/server-target.json.

What I expected

A screen that names the unreachable server and offers Retry and Use This Mac, the way the builtin and Connect-authentication failures already do.

Where it goes wrong

All references are on main at 0a985e6.

  1. At startup, a non-builtin saved target goes to applyServerTarget() without a guard — apps/desktop/src/main.ts:2214.

  2. The custom branch loads the remote URL directly — apps/desktop/src/main.ts:1199-1207:

    bbAppLoaded = true;
    await loadWindowUrl({ url: target.url });

    BrowserWindow.loadURL rejects with ERR_FAILED when the host is unreachable (host asleep, Tailscale down, server not running). Nothing catches it.

  3. The rejection unwinds to the top-level handler — apps/desktop/src/main.ts:2219-2228 — which renders error.stack. That is why the user-facing text is Electron internals rather than a description of the problem.

  4. The error view is static HTML under default-src 'none' — apps/desktop/src/local-view.ts:55-66, 81. It cannot carry a button, so the screen is terminal by construction.

The same unguarded load exists on the connect branch at apps/desktop/src/main.ts:1194. That branch handles authentication failure gracefully (main.ts:1179-1187), but a successful authentication followed by an unreachable page load fails the same way. The builtin branch is the one that already does this well (main.ts:1144-1153).

Two related consequences of the throw:

  • refreshApplicationMenu() at the end of applyServerTarget() (main.ts:1208) never runs, so the Server menu keeps showing the failed target as active.
  • bbAppLoaded is set to true at main.ts:1201 before the load is known to have succeeded, so the app's own state says the workspace is loaded while the error screen is showing.

Suggested fix

The pieces are already in the tree:

  • probeBbServer / waitForCompatibleServer in apps/desktop/src/server-probe.ts are used today only for the local server. Probing a remote target before loading it would turn this into a handled outcome rather than a rejected promise.
  • Wrap the custom and connect page loads in the same shape as the builtin branch: on failure, call loadStartupError with a message naming the server and the fact that it is unreachable, then refreshApplicationMenu().
  • Set bbAppLoaded = true only after the load resolves.
  • Give the startup error view actionable recovery. That needs either a preload-backed local view instead of the current data: URL, or at minimum error copy that names Window ▸ Server ▸ This Mac as the way out.

I am happy to open a pull request for this. Flagging it first since the last item touches how the local view is rendered, and per CONTRIBUTING.md that is closer to a UI change than a pure bug fix.

Environment

  • macOS on an M1 MacBook Pro (desktop app), server on a separate Linux host
  • Target kind: custom, plain http:// over a Tailscale hostname
  • Reproduces on launch, every time the target is unreachable

Activity

  1. added theissue type on Aug 13, 2026
  2. added
    desktop
    on Aug 18, 2026
  3. SawyerHood commented on Aug 18, 2026

    @SawyerHood
    Collaborator

    Reproduction & root-cause report: https://get-bb.github.io/reports/issues/1494.html

    • Verdict: REPRODUCED · root-cause confidence: high
    • Root cause (short): applyServerTarget() awaits loadWindowUrl for custom/connect targets with no try/catch, so an unreachable host's BrowserWindow.loadURL rejection unwinds to runDesktopApp's crash handler which renders error.stack into a static, script-less (default-src 'none') error view with no controls; from the Server menu the same rejection is unhandled and leaves a blank window.
    • Proposed fix: (1) In apps/desktop/src/main.ts applyServerTarget(), wrap the custom and connect loadWindowUrl calls in try/catch (or a small loadRemoteServerPage helper): on rejection log the Electron detail, call loadStartupError with a message naming the redacted server origin and pointing at Window ▸ Server / This Mac, stop Connect session renewal on the connect branch, and refreshApplicationMenu(); set bbAppLoaded = true only after the load resolves and isCurrent() holds. This also fixes the blank-window unhandled-rejection path from the Server menu. (2) Give the local error view real Retry / Use This Ma…
    • Caveats: Reproduced on Linux under Xvfb with the built desktop shell (Electron 41.7.0), not on macOS; error codes seen were ERR_CONNECTION_REFUSED / ERR_CONNECTION_TIMED_OUT / ERR_UNSAFE_PORT rather than the reporter's ERR_FAILED, but all take the identical code path. The connect-branch variant was verified by code only (no bb Connect server available). The issue's claim that bbAppLoaded stays true is refu…

    The report has copy-paste repro steps, screenshots where the bug is visual, code permalinks at 16ceb3a54, and repro artifacts. It was independently re-run by a second agent (see its Verification section).

    AGENT GENERATED: by Claude Opus 5

  4. added
    confirmed-repro
    on Aug 18, 2026
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

    confirmed-reprodesktop

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions