#4880 · Move freeze incorrectly clears the live connect account
Verdict: REPRODUCED · Root-cause confidence: high
1. TL;DR
During a server move, the source server pauses public writes but deliberately keeps its account and connect plugins running. Those plugins still communicate through POST RPCs, so the freeze rejects their account reads with HTTP 503 and code server_moving. Connect collapses that temporary response into an account-unavailable error, clears its last known account, and closes the live tunnel. A local test with the real account and connect plugins reproduces the disconnect after the real 25-second long-poll expires; a separate real freeze-middleware and SDK test verifies the HTTP-to-error translation. Both failures repeat in a second clean checkout of the same trusted main commit.
2. Claims vs findings
| Claim | Finding | Evidence |
|---|---|---|
| The move retains the account and connect plugins. | Verified in source | The move environment excludes both plugin sources from suspension. |
| The freeze blocks account status, wait, and credential RPCs. | Verified dynamically | The Hono reproduction requests all three routes and checks status 503 and code server_moving. |
| The account long-poll has a 25-second deadline. | Verified | Trusted contract and account implementation; both plugin reproductions fail after approximately 25.1 seconds. |
| The freeze is interpreted as losing the account and tears down connect. | Verified dynamically | The HTTP bridge loses the server_moving code; the plugin test observes paired=false and disconnected after two blocked reads. |
| A real macOS-to-Ubuntu move fails during transfer, then reconnects on rollback. | Unverified end to end | No production accounts, enrolled machines, or user runtime were used. This report reproduces the causal account/tunnel failure, not a complete migration. |
| A locally modified desktop bundle completed a move. | Unverified | No issue-supplied bundle, patch, command, or PR branch was executed. |
| The same cause explains earlier migration failures. | Unverified for those incidents | Related issues were not reproduced here. |
3. Environment
- Public target repository: get-bb/bb; trusted origin/main commit
300a08b859f7786452c4fcab4e3a2bef56b823bb; checked again before applying the fix. - Linux x86_64, Node v22.19.0, pnpm 9.15.0, Vitest 4.1.1; source package bb-app 0.45.0.
- Two separate temporary clones. Both use frozen-lockfile installation and the normal Turbo build: 63 successful tasks each.
- No live BB server, daemon, browser, provider, production tunnel, or persistent runtime data. The real plugin implementations run in the repository's plugin harness with fresh local StubGetbb HTTP/WebSocket servers on ephemeral loopback ports and disposable harness storage. The HTTP bridge uses Hono in process, requiring no listening port.
4. Minimal reproduction
The integration test injects a typed server-moving HTTP failure only at the plugin RPC boundary; it does not implement account classification, AccountLink retry behavior, or tunnel teardown. Those are the production implementations. The second reproduction connects actual freeze middleware, HTTP serialization, SDK parsing, and the actual account client, removing uncertainty about the injected error shape.
- Start a fresh trusted checkout, install existing dependencies, and build:
git clone --branch main https://github.com/get-bb/bb.git bb-4880 cd bb-4880 git checkout --detach 300a08b859f7786452c4fcab4e3a2bef56b823bb pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build
- Copy the complete regression diff below into
regression.diffand apply it to this checkout:git apply regression.diff
Only test code changes; production code remains unchanged. - Run the account/tunnel regression:
pnpm exec turbo run test --filter=bb-plugin-connect -- src/account-integration.test.ts -t 'keeps the live tunnel through a server move freeze'
- Expected: account remains paired, connect stays connected, the same live WebSocket remains open, and account polling resumes after the pause without another tunnel dial. Actual on trusted main (exit 1):
bb-plugin-connect:test: AssertionError: expected { state: 'disconnected', …(11) } to match object { paired: true, state: 'connected' } bb-plugin-connect:test: (10 matching properties omitted from actual) bb-plugin-connect:test: bb-plugin-connect:test: - Expected bb-plugin-connect:test: + Received bb-plugin-connect:test: bb-plugin-connect:test: { bb-plugin-connect:test: - "paired": true, bb-plugin-connect:test: - "state": "connected", bb-plugin-connect:test: + "paired": false, bb-plugin-connect:test: + "state": "disconnected", bb-plugin-connect:test: } bb-plugin-connect:test: - Copy the complete HTTP bridge test below into
apps/server/test/server-move/account-freeze-repro.test.tsand run:pnpm exec turbo run test --filter=@bb/server -- test/server-move/account-freeze-repro.test.ts
All three account RPC paths return the expected freeze error. The final assertion fails because the client replacesBbHttpError(status=503, code=server_moving)withAccountUnavailableError.
Focused regression added to the existing integration suite
it("keeps the live tunnel through a server move freeze and resumes account polling", async () => {
await loadBoth();
await signInAccount();
startTunnel();
await waitForConnected(1);
const socket = stub.tunnelDials[0]!.socket!;
serverMoving = true;
await vi.waitFor(
() => expect(blockedAccountReads).toBeGreaterThanOrEqual(2),
{ timeout: 30_000 },
);
expect(await connectStatus()).toMatchObject({
paired: true,
state: "connected",
});
expect(socket.readyState).toBe(1);
const readsBeforeResume = successfulAccountReads;
serverMoving = false;
await vi.waitFor(() =>
expect(successfulAccountReads).toBeGreaterThan(readsBeforeResume),
);
expect(await connectStatus()).toMatchObject({
paired: true,
state: "connected",
});
expect(stub.tunnelDials).toHaveLength(1);
expect(socket.readyState).toBe(1);
}, 35_000);
Complete regression diff, including setup and RPC-boundary injection
diff --git a/plugins/connect/src/account-integration.test.ts b/plugins/connect/src/account-integration.test.ts
index d91b6bf..abb0169 100644
--- a/plugins/connect/src/account-integration.test.ts
+++ b/plugins/connect/src/account-integration.test.ts
@@ -36,12 +36,24 @@ let stub: StubGetbb;
let accountHost: FakePluginHost;
let connectHost: FakePluginHost;
let accountRunning = true;
+let serverMoving = false;
+let blockedAccountReads = 0;
+let successfulAccountReads = 0;
let credentialReads = 0;
let failCredentialRead: number | null = null;
let tunnelService: { controller: AbortController; done: Promise<void> } | null =
null;
function callAccountRpc(args: RpcArgs): Promise<unknown> {
+ if (serverMoving) {
+ blockedAccountReads += 1;
+ return Promise.reject(
+ Object.assign(new Error("HTTP 503: Changes are paused"), {
+ status: 503,
+ code: "server_moving",
+ }),
+ );
+ }
if (args.method === "bb-account.v1.connectCredential") credentialReads += 1;
const failRead =
args.method === "bb-account.v1.connectCredential" &&
@@ -57,7 +69,10 @@ function callAccountRpc(args: RpcArgs): Promise<unknown> {
.callRpc(args.method, args.input ?? null, {
experimental_caller: { kind: "plugin", pluginId: "connect" },
})
- .then((result) => args.outputSchema.parse(result));
+ .then((result) => {
+ successfulAccountReads += 1;
+ return args.outputSchema.parse(result);
+ });
const signal = args.signal;
if (signal === undefined) return call;
return new Promise((resolve, reject) => {
@@ -144,6 +159,9 @@ async function storedCredential(): Promise<string> {
beforeEach(async () => {
stub = await StubGetbb.start();
accountRunning = true;
+ serverMoving = false;
+ blockedAccountReads = 0;
+ successfulAccountReads = 0;
credentialReads = 0;
failCredentialRead = null;
});
@@ -160,6 +178,38 @@ afterEach(async () => {
});
describe("connect on top of bb account", () => {
+ it("keeps the live tunnel through a server move freeze and resumes account polling", async () => {
+ await loadBoth();
+ await signInAccount();
+ startTunnel();
+ await waitForConnected(1);
+ const socket = stub.tunnelDials[0]!.socket!;
+
+ serverMoving = true;
+ await vi.waitFor(
+ () => expect(blockedAccountReads).toBeGreaterThanOrEqual(2),
+ { timeout: 30_000 },
+ );
+
+ expect(await connectStatus()).toMatchObject({
+ paired: true,
+ state: "connected",
+ });
+ expect(socket.readyState).toBe(1);
+
+ const readsBeforeResume = successfulAccountReads;
+ serverMoving = false;
+ await vi.waitFor(() =>
+ expect(successfulAccountReads).toBeGreaterThan(readsBeforeResume),
+ );
+ expect(await connectStatus()).toMatchObject({
+ paired: true,
+ state: "connected",
+ });
+ expect(stub.tunnelDials).toHaveLength(1);
+ expect(socket.readyState).toBe(1);
+ }, 35_000);
+
it("waits while signed out, then dials the gate with the account's credential the moment it signs in", async () => {
await loadBoth();
startTunnel();
Complete freeze/SDK bridge reproduction
import { createBbSdk, createHttpTransport } from "@bb/sdk/browser";
import { Hono } from "hono";
import { expect, it } from "vitest";
import { createAccountClient } from "../../../../plugins/connect/src/account-client.js";
import { ApiError } from "../../src/errors.js";
import { serverMoveFreezeMiddleware } from "../../src/services/server-move/freeze.js";
it("preserves the server-moving error through the account client", async () => {
const app = new Hono();
app.onError((error) => {
if (error instanceof ApiError) return error.toResponse();
throw error;
});
app.use("/api/v1/*", serverMoveFreezeMiddleware({ isFrozen: () => true }));
app.post("/api/v1/*", (context) => context.json({ ok: true }));
const sdk = createBbSdk({
transport: createHttpTransport({
baseUrl: "http://repro.invalid",
runtime: "browser",
fetch: (input, init) => app.request(input, init),
}),
});
for (const method of [
"bb-account.v1.status",
"bb-account.v1.waitForStatusChange",
"bb-account.v1.connectCredential",
]) {
const response = await app.request(
`/api/v1/plugins/bb-account/rpc/${method}`,
{ method: "POST" },
);
expect(response.status).toBe(503);
expect(await response.json()).toMatchObject({ code: "server_moving" });
}
const account = createAccountClient(() => sdk);
await expect(account.status()).rejects.toMatchObject({
name: "BbHttpError",
status: 503,
code: "server_moving",
});
});
5. Root cause
The write freeze classifies all non-move POST routes as writes, including plugin RPCs that only read account state. The SDK preserves the freeze's distinct error code, but the account client throws that information away when it translates every 503 into account unavailable. AccountLink reserves that error for situations in which it must clear the account, so it calls the connect tunnel with null. Connect's existing identity-change path then tears down the current tunnel. The retry path cannot restore the account while status RPCs continue returning the freeze response.
apps/server/src/services/server-move/freeze.ts:11
export function isServerMoveFreezeExempt(
method: string,
path: string,
): boolean {
return READ_METHODS.has(method) || SERVER_MOVE_ROUTE_PATTERN.test(path);
}
export function serverMoveFreezeMiddleware(
state: ServerMoveFreezeState,
): MiddlewareHandler {
return async (context, next) => {
if (
state.isFrozen() &&
!isServerMoveFreezeExempt(context.req.method, context.req.path)
) {
throw serverMovingError();
}
await next();
};
apps/server/src/services/server-move/freeze-state.ts:37
export function serverMovingError(): ApiError {
return new ApiError(
503,
"server_moving",
"The server is moving to another machine. Changes are paused until the move finishes or is cancelled.",
false,
);
}
packages/sdk/src/areas/plugins.ts:418
async callRpc(input) {
const envelope = await requestParsed(
pluginPath(input.pluginId, `/rpc/${encodeURIComponent(input.method)}`),
z.object({ ok: z.literal(true), result: jsonValueSchema }),
{ ...jsonInit("POST", input.input ?? null), signal: input.signal },
);
return input.outputSchema.parse(envelope.result);
},
async checkUpdates(input = {}) {
packages/sdk/src/response.ts:150
}
if (!response.ok) {
const { body, code, message } = await readHttpErrorInfo(response);
throw new BbHttpError({ body, code, message, status: response.status });
}
return response;
plugins/connect/src/account-client.ts:147
} catch (error) {
const status = httpStatusOf(error);
if (status === 503 || status === 404) {
throw new AccountUnavailableError(`HTTP ${status}`);
}
throw error;
plugins/connect/src/account-link.ts:62
} catch (error) {
if (signal.aborted) return;
if (error instanceof AccountUnavailableError) {
this.options.onAccount(null);
} else {
this.options.log.warn(
`could not read the bb account status: ${errorMessage(error)}`,
);
}
revision = null;
syncedRevision = null;
failures += 1;
const base = this.options.retryMinMs ?? RETRY_MIN_MS;
await sleep(Math.min(base * 2 ** (failures - 1), RETRY_MAX_MS), signal);
plugins/connect/src/tunnel.ts:107
setAccount(account: Account | null): void {
const next = identityOf(account);
if (sameIdentity(this.identity, next)) return;
const running = !this.stopped;
this.teardown();
this.options.shares.clearMachineDeclarations();
this.identity = next;
this.lastError = null;
if (running) {
this.stopped = false;
this.openTunnel();
this.startShareActivation();
}
this.publish();
plugins/bb-account/src/contract.ts:20
export const WAIT_FOR_STATUS_CHANGE_METHOD = "bb-account.v1.waitForStatusChange"; export const FETCH_METHOD = "bb-account.v1.fetch"; export const ADOPT_CONNECT_CREDENTIAL_METHOD = "bb-account.v1.adoptConnectCredential"; export const CONNECT_CREDENTIAL_METHOD = "bb-account.v1.connectCredential"; export const CONFIRM_REFUSED_CREDENTIAL_METHOD = "bb-account.v1.confirmRefusedCredential"; export const LONG_POLL_TIMEOUT_MS = 25_000;
plugins/bb-account/src/account.ts:129
waitForStatusChange(afterRevision: number): Promise<AccountStatus> {
if (this.revision > afterRevision || this.disposed) {
return Promise.resolve(this.status());
}
return new Promise((resolve) => {
const finish = () => {
clearTimeout(timer);
this.waiters.delete(finish);
resolve(this.status());
};
const timer = setTimeout(finish, LONG_POLL_TIMEOUT_MS);
timer.unref?.();
this.waiters.add(finish);
});
}
apps/server/src/services/server-move/environment.ts:133
setSchedulesPaused: (paused) => pluginService.setSchedulesPaused(paused),
stop: () => pluginService.stop(),
suspendAllButConnect: async () => {
await pluginService.suspendPlugins({
keep: (plugin) =>
CONNECT_HOLD_SOURCES.some((source) => source === plugin.source),
});
This is a distinction between a paused server and an absent account plugin, not a transport reset. Approximately 25 seconds is the maximum wait until an already active long-poll returns under otherwise stable conditions, not a universal timer from the start of every move.
6. Proposed fix
In connect's existing account RPC error boundary, retain the original error specifically when its status is 503 and its code is server_moving. AccountLink already logs and retries non-unavailable failures without clearing the last known account. Keep normal missing/stopped-plugin responses, actual sign-out, and credential rejection behavior unchanged. This changes neither the freeze allowlist nor any authentication or authorization rule, protocol, package, data schema, or stored data.
The proposed local fix changes only the connect client and its existing integration test. It addresses this account-poll-induced teardown, not every remaining failure in a full server move. In particular, a blocked move-time grant is a separate concern.
7. Verification
The same agent created checkout 2 from the recorded trusted commit, detached HEAD, ran a fresh frozen install and a successful normal Turbo build, and copied only the two new reproduction tests. Production code in checkout 2 remained byte-for-byte at the trusted commit. No issue patch or PR branch was used.
| Run | Command | Observed result |
|---|---|---|
| Checkout 1 / unchanged production | Connect integration command above | Exit 1; disconnected and unpaired; test duration 25.112 s. |
| Checkout 2 / unchanged production | Same connect integration command | Exit 1; same disconnect and unpairing; test duration 25.143 s. |
| Checkout 1 / unchanged production | Server bridge command above | Exit 1; AccountUnavailableError replaces BbHttpError after successful freeze-route checks. |
| Checkout 2 / unchanged production | Same server bridge command | Exit 1; same error translation failure. |
| Checkout 1 / local client fix | Connect integration command | Exit 0; same tunnel socket stays open and polling resumes without redial. |
No correction was needed after the second clean run. This is repeated verification by the same agent, not independent verification. Limits: no actual server data transfer, enrolled-daemon session, macOS desktop, or production gate was exercised.
After the local fix, pnpm exec turbo run test typecheck lint --filter=bb-plugin-connect completed successfully: all 134 plugin tests in six files passed and the plugin typecheck passed. This plugin has no lint script, so the requested Turbo lint task did not run a plugin linter. Existing sign-out, credential-rejection, and stopped-account coverage remained green. pnpm exec turbo run test --filter=@bb/server -- test/server-move/account-freeze-repro.test.ts test/server-move/freeze.test.ts test/server-move/connect-hold.test.ts also passed all four tests in three files. The server bridge is investigation evidence only, not part of the proposed patch.
8. Related issues
#4837 concerns another account RPC during a move. #4394 concerns migration disconnections. These are context only; this investigation does not prove their exact root causes. No open pull request linking #4880 was present when checked before the fix.
9. Appendix
Raw local evidence is retained privately, not committed to the public report repository. Reproduction sources and the exact observed mismatch are inline so no artifact download is needed.
Second clean tunnel run
⎯⎯⎯⎯⎯⎯⎯
bb-plugin-connect:test:
bb-plugin-connect:test: FAIL |bb-plugin-connect| src/account-integration.test.ts > connect on top of bb account > keeps the live tunnel through a server move freeze and resumes account polling
bb-plugin-connect:test: AssertionError: expected { state: 'disconnected', …(11) } to match object { paired: true, state: 'connected' }
bb-plugin-connect:test: (10 matching properties omitted from actual)
bb-plugin-connect:test:
bb-plugin-connect:test: - Expected
bb-plugin-connect:test: + Received
bb-plugin-connect:test:
bb-plugin-connect:test: {
bb-plugin-connect:test: - "paired": true,
bb-plugin-connect:test: - "state": "connected",
bb-plugin-connect:test: + "paired": false,
bb-plugin-connect:test: + "state": "disconnected",
bb-plugin-connect:test: }
bb-plugin-connect:test:
bb-plugin-connect:test: ❯ src/account-integration.test.ts:194:35
bb-plugin-connect:test: 192| );
bb-plugin-connect:test: 193|
bb-plugin-connect:test: 194| expect(await connectStatus()).toMatchObject({
bb-plugin-connect:test: | ^
bb-plugin-connect:test: 195| paired: true,
bb-plugin-connect:test: 196| state: "connected",
bb-plugin-connect:test:
bb-plugin-connect:test: ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
bb-plugin-connect:test:
bb-plugin-connect:test:
bb-plugin-connect:test: Test Files 1 failed (1)
bb-plugin-connect:test: Tests 1 failed | 11 skipped (12)
bb-plugin-connect:test: Start at 02:27:02
bb-plugin-connect:test: Duration 26.52s (transform 854ms, setup 0ms, import 1.19s, tests 25.14s, environment 0ms)
bb-plugin-connect:test:
bb-plugin-connect:test: ELIFECYCLE Test failed. See above for more details.
bb-plugin-connect#test: ERROR command (<checkout-2>/plugins/connect) /usr/local/bin/pnpm run test src/account-integration.test.ts -t keeps the live tunnel through a server move freeze exited (1)
Tasks: 4 successful, 5 total
Cached: 0 cached, 5 total
Time: 28.482s
Failed: bb-plugin-connect#test
ERROR run failed: command exited (1)
Second clean HTTP bridge run
⎯⎯⎯⎯⎯⎯⎯
@bb/server:test:
@bb/server:test: FAIL |@bb/server| test/server-move/account-freeze-repro.test.ts > preserves the server-moving error through the account client
@bb/server:test: AssertionError: expected AccountUnavailableError: bb account isn't… to match object { name: 'BbHttpError', …(2) }
@bb/server:test:
@bb/server:test: - Expected
@bb/server:test: + Received
@bb/server:test:
@bb/server:test: - {
@bb/server:test: - "code": "server_moving",
@bb/server:test: - "name": "BbHttpError",
@bb/server:test: - "status": 503,
@bb/server:test: + AccountUnavailableError {
@bb/server:test: + "name": "AccountUnavailableError",
@bb/server:test: }
@bb/server:test:
@bb/server:test: ❯ test/server-move/account-freeze-repro.test.ts:38:33
@bb/server:test: 36|
@bb/server:test: 37| const account = createAccountClient(() => sdk);
@bb/server:test: 38| await expect(account.status()).rejects.toMatchObject({
@bb/server:test: | ^
@bb/server:test: 39| name: "BbHttpError",
@bb/server:test: 40| status: 503,
@bb/server:test:
@bb/server:test: ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
@bb/server:test:
@bb/server:test:
@bb/server:test: Test Files 1 failed (1)
@bb/server:test: Tests 1 failed (1)
@bb/server:test: Start at 02:28:33
@bb/server:test: Duration 2.27s (transform 1.31s, setup 1.46s, import 584ms, tests 31ms, environment 0ms)
@bb/server:test:
@bb/server:test: ELIFECYCLE Test failed. See above for more details.
@bb/server#test: ERROR command (<checkout-2>/apps/server) /usr/local/bin/pnpm run test test/server-move/account-freeze-repro.test.ts exited (1)
Tasks: 8 successful, 9 total
Cached: 0 cached, 9 total
Time: 30.123s
Failed: @bb/server#test
ERROR run failed: command exited (1)
Fixed plugin suite result
bb-plugin-connect:test: ✓ |bb-plugin-connect| src/tunnel-lifecycle.test.ts (15 tests) 89ms bb-plugin-connect:test: ✓ |bb-plugin-connect| app.test.tsx (19 tests) 887ms bb-plugin-connect:test: ✓ |bb-plugin-connect| src/connect.test.ts (71 tests) 2419ms bb-plugin-connect:test: ✓ backs off while getbb.app can't answer the adoption 502ms bb-plugin-connect:test: ✓ |bb-plugin-connect| src/account-integration.test.ts (12 tests) 29880ms bb-plugin-connect:test: ✓ keeps the live tunnel through a server move freeze and resumes account polling 25232ms bb-plugin-connect:test: ✓ redials with the credential after the gate drops the tunnel 1390ms bb-plugin-connect:test: ✓ signs out everywhere when getbb.app rejects the credential 1228ms bb-plugin-connect:test: ✓ retries when bb account is briefly unavailable while handing over the credential 1381ms bb-plugin-connect:test: bb-plugin-connect:test: Test Files 6 passed (6) bb-plugin-connect:test: Tests 134 passed (134) bb-plugin-connect:test: Start at 02:31:53 bb-plugin-connect:test: Duration 31.59s (transform 3.65s, setup 0ms, import 5.81s, tests 33.42s, environment 860ms) bb-plugin-connect:test: Tasks: 7 successful, 7 total Cached: 4 cached, 7 total Time: 33.18s
Investigation commands: trusted repository metadata and issue/comment reads with GitHub CLI; trusted main clone/fetch and commit inspection; frozen installation; Turbo build; the two exact Turbo reproduction commands above; source line inspection using git show at the recorded commit. The integration uses the real 25-second long-poll rather than fake timers. All local loopback servers and services close in the test's afterEach hooks.
Issue content was treated as untrusted claims. No embedded instruction, command, patch, external issue link, or linked PR code was executed.