← reports

#7500 · Persistent Connect transport: clean-checkout liveness investigation

BugHighEffort: Mediumremote · connect · no-reproGitHub issue

November 13, 2026 · trusted origin/main 88cf8f644c81fca797ad80bc31bb36a61ce5cc9b

Verdict: NOT REPRODUCED · Root-cause confidence: low

1. TL;DR

The reported Windows deployment loses Connect and remote commands repeatedly; its unauthenticated persistent HTTPS requests reportedly stall too. I could not reproduce that failure on trusted main in this Linux environment. In each of two clean source checkouts, the real TunnelSession and real TunnelDO stayed connected for over 90 seconds, served 49 HTTPS requests on one reused TLS connection, and delivered 46 WebSocket echo replies. The local gate acknowledged heartbeats, and all 37 selected existing tests passed. These results do not test the reporter’s Windows network stack or the deployed account edge, and do not invalidate the reported symptoms.

2. Claims vs findings

ClaimStatusEvidence
Connect consistently drops near the first heartbeat.Unverified in affected environmentNo unexpected close in either 90-second local run; heartbeat acknowledgements arrived.
The second persistent HTTPS request stalls.Not reproduced locally49/49 requests succeeded per run; 48 reused requests and exactly one TLS socket. This is a loopback gate/relay probe returning 200, not a deployed account’s anonymous 401 route.
A lost tunnel also loses proxied WebSockets.Supported by source, not a reproduction of the initiating faultTunnelDO abandons streams on tunnel loss; TunnelSession closes origin sockets on disposal.
The client heartbeat watchdog causes 20–30-second closes.Not supported under a normal clock20-second send interval, strictly greater than 60-second watchdog threshold; the regular first termination without any acknowledgements is at the 80-second tick.
VPN, ISP path, packet loss, particular edge address, and alternate public service controls distinguish the cause.UnverifiedNo access to the affected hardware, account, network path, or independent packet captures. Reporter observations are not treated as measurements from this investigation.

3. Environment

4. Minimal reproduction / transport probe

This is an investigator-authored test of the reported transport failure, not a script taken from the issue. Expected healthy behavior: subsequent TLS requests complete, echo messages return, heartbeats are acknowledged, and the tunnel survives beyond 90 seconds. A reproduction would instead fail a request/echo/close assertion, or terminate without the expected summary.

  1. Obtain a clean trusted checkout and build with the existing lockfile and dependencies:
    git clone https://github.com/get-bb/bb.git bb-7500-first
    cd bb-7500-first
    git checkout --detach 88cf8f644c81fca797ad80bc31bb36a61ce5cc9b
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build
  2. Save the fixture below as apps/connect/test/issue-7500-fixture.ts, and the probe as apps/connect/test/issue-7500-repro.mjs. Both are complete, inline, and use only already-installed dependencies. Ensure the two explicit loopback ports are unused; a busy port fails the run rather than connecting to an existing service.
  3. From the repository root run:
    node --conditions=source --import tsx apps/connect/test/issue-7500-repro.mjs 49151 49152
    pnpm exec turbo run test --filter=@bb/tunnel-client
    pnpm exec turbo run test --filter=@bb/connect -- response-encoding.test.ts

Actual first-run output (exit 0):

{
  "result": "PASS",
  "elapsedMs": 90846,
  "httpsRequests": 49,
  "reusedRequests": 48,
  "distinctHttpsSockets": 1,
  "websocketEchoReplies": 46,
  "heartbeatAcknowledged": true,
  "unexpectedTunnelClose": false,
  "warnings": []
}

Existing suites: tunnel-client 7 files / 27 tests passed; Connect response-encoding 1 file / 10 tests passed. Both frozen installs and both full builds succeeded, with 73 build tasks per checkout. Build-time web route generation was restored; no production code was changed.

Complete fixture
export { TunnelDO } from "../src/tunnel-do.js";

export default {
  fetch(request: Request, env: { TUNNEL_DO: DurableObjectNamespace }) {
    return env.TUNNEL_DO.get(env.TUNNEL_DO.idFromName("isolated-repro")).fetch(
      request,
    );
  },
};
Complete transport probe
import assert from "node:assert/strict";
import { once } from "node:events";
import { createServer } from "node:http";
import { Agent, get } from "node:https";
import { createRequire } from "node:module";
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { setTimeout as delay } from "node:timers/promises";
import { fileURLToPath } from "node:url";
import { build } from "esbuild";
import { Miniflare } from "miniflare";
import { workerNodeBuiltinsPlugin } from "@bb/connect-db-pg/testing";
import { TunnelSession } from "../../../packages/tunnel-client/src/session.ts";

const requireTunnel = createRequire(
  new URL("../../../packages/tunnel-client/package.json", import.meta.url),
);
const { WebSocket, WebSocketServer } = requireTunnel("ws");
const originPort = Number(process.argv[2]);
const gatePort = Number(process.argv[3]);
assert(Number.isInteger(originPort) && originPort >= 40000 && originPort <= 60000);
assert(Number.isInteger(gatePort) && gatePort >= 40000 && gatePort <= 60000);
assert.notEqual(originPort, gatePort);
const stateDirectory = await mkdtemp(join(tmpdir(), "bb-7500-state-"));
const origin = createServer((_request, response) => {
  response.writeHead(200, { "content-type": "text/plain" });
  response.end("fixture-ok");
});
origin.keepAliveTimeout = 120000;
const originWebSockets = new WebSocketServer({ server: origin });
originWebSockets.on("connection", (socket) => {
  socket.on("message", (data, binary) => socket.send(data, { binary }));
});
const agent = new Agent({ keepAlive: true, maxSockets: 1, rejectUnauthorized: false });
let runtime;
let tunnel;
let session;
let visitor;
let tunnelClosed = false;
const warnings = [];
const reused = [];
const localPorts = new Set();
let replies = 0;
const started = Date.now();

async function request() {
  return await new Promise((resolve, reject) => {
    const pending = get(`https://127.0.0.1:${gatePort}/probe`, { agent }, (response) => {
      const chunks = [];
      localPorts.add(response.socket.localPort);
      response.on("data", (chunk) => chunks.push(chunk));
      response.on("error", reject);
      response.on("end", () => {
        assert.equal(response.statusCode, 200);
        assert.equal(Buffer.concat(chunks).toString(), "fixture-ok");
        reused.push(pending.reusedSocket);
        resolve();
      });
    });
    pending.setTimeout(5000, () => pending.destroy(new Error("request timeout")));
    pending.on("error", reject);
  });
}

async function echo(index) {
  const incoming = once(visitor, "message");
  visitor.send(`probe-${index}`);
  const [data] = await Promise.race([
    incoming,
    delay(5000).then(() => { throw new Error("echo timeout"); }),
  ]);
  assert.equal(data.toString(), `probe-${index}`);
  replies += 1;
}

try {
  await new Promise((resolve, reject) => {
    origin.once("error", reject);
    origin.listen(originPort, "127.0.0.1", resolve);
  });
  const bundled = await build({
    entryPoints: [fileURLToPath(new URL("issue-7500-fixture.ts", import.meta.url))],
    bundle: true,
    format: "esm",
    target: "esnext",
    conditions: ["workerd", "worker", "browser"],
    plugins: [workerNodeBuiltinsPlugin],
    write: false,
  });
  runtime = new Miniflare({
    host: "127.0.0.1",
    port: gatePort,
    https: true,
    modules: true,
    script: bundled.outputFiles[0].text,
    compatibilityDate: "2026-06-11",
    compatibilityFlags: ["nodejs_compat"],
    durableObjects: { TUNNEL_DO: "TunnelDO" },
    durableObjectsPersist: stateDirectory,
  });
  await runtime.ready;
  tunnel = new WebSocket(`wss://127.0.0.1:${gatePort}/__tunnel?v=1`, {
    rejectUnauthorized: false,
  });
  tunnel.on("close", () => { tunnelClosed = true; });
  await once(tunnel, "open");
  session = new TunnelSession({
    tunnel,
    log: { warn: (message) => warnings.push(message) },
    resolveOrigin: () => ({
      kind: "ok",
      resolved: {
        origin: `http://127.0.0.1:${originPort}`,
        publicOrigin: `https://127.0.0.1:${gatePort}`,
      },
    }),
  });
  session.start();
  visitor = new WebSocket(`wss://127.0.0.1:${gatePort}/echo`, {
    rejectUnauthorized: false,
  });
  await once(visitor, "open");
  await request();
  await request();
  await request();
  for (let index = 0; index < 46; index += 1) {
    if (index > 0) await delay(2000);
    await request();
    await echo(index);
    assert.equal(tunnelClosed, false);
    if (index > 10) assert.notEqual(session.lastHeartbeatAckAt, null);
  }
  assert.equal(localPorts.size, 1);
  assert.equal(reused.filter(Boolean).length, 48);
  assert.equal(warnings.length, 0);
  console.log(JSON.stringify({
    result: "PASS",
    elapsedMs: Date.now() - started,
    httpsRequests: reused.length,
    reusedRequests: reused.filter(Boolean).length,
    distinctHttpsSockets: localPorts.size,
    websocketEchoReplies: replies,
    heartbeatAcknowledged: session.lastHeartbeatAckAt !== null,
    unexpectedTunnelClose: tunnelClosed,
    warnings,
  }, null, 2));
} finally {
  agent.destroy();
  visitor?.terminate();
  session?.dispose();
  tunnel?.terminate();
  for (const socket of originWebSockets.clients) socket.terminate();
  originWebSockets.close();
  origin.closeAllConnections();
  await new Promise((resolve) => origin.close(resolve));
  await runtime?.dispose();
  await rm(stateDirectory, { recursive: true, force: true });
}

5. Root cause: not established

No initiating defect was reproduced on trusted main. No claim is made that the deployed edge, an ISP, Windows, or a VPN driver is at fault. The following source facts constrain the next investigation:

6. Proposed next experiment / fix safety

No speculative fix or pull request is safe: there is no failing regression on trusted main, and the actual Windows/deployed-edge fault is not reproduced. In particular, increasing heartbeat timeouts or forcing Connection: close would only hide a transport symptom and would not explain an anonymous HTTPS response stalling.

Next, compare the affected Windows machine on another network with another machine on the affected network, using a credential-free repeated-request probe written independently from the report. Compare HTTP/1.1 connection reuse with fresh sockets, then HTTP/2 where supported. Correlate exact request times with sanitized Worker request identifiers and stored Workers Logs (never attach production live tail). A controlled Windows test with the VPN background driver fully removed would help isolate a driver effect; merely closing its UI does not do so. Packet captures should be private and scrubbed of identities and credentials before any sharing.

The GitHub cross-reference/connected-event timeline contained no linked pull request at review time. A text-search PR hit was unrelated and did not link this issue; it was not run or checked out.

7. Verification: second clean checkout, same investigator

A separately created clean worktree at the exact trusted base was confirmed clean, then frozen-installed and built. Only the two probe files authored here were copied into it. It used distinct ports, a fresh temporary state directory, and a new runtime. This is a repeat by the same agent, not independent verification.

git worktree add --detach /tmp/bb-7500-second 88cf8f644c81fca797ad80bc31bb36a61ce5cc9b
cd /tmp/bb-7500-second
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build
node --conditions=source --import tsx apps/connect/test/issue-7500-repro.mjs 49161 49162

Save the same inline files before the last command. The directory names here are portable instructions, not disclosure of runtime paths. Actual second-run output (exit 0):

{
  "result": "PASS",
  "elapsedMs": 90688,
  "httpsRequests": 49,
  "reusedRequests": 48,
  "distinctHttpsSockets": 1,
  "websocketEchoReplies": 46,
  "heartbeatAcknowledged": true,
  "unexpectedTunnelClose": false,
  "warnings": []
}

All asserted invariants held in both runs. No correction to the first run’s conclusions was needed. The second result supports only the scoped NOT REPRODUCED verdict, not a claim that the reporter’s deployment works. Code links were checked against the recorded commit. Both probe processes exited, disposed their runtimes, and removed their temporary persistence state.

8. Related issues

9. Appendix / evidence and trust boundary

The complete executed transport probe and its verbatim summaries are included inline above. The executed validation commands are listed in the reproduction and Verification sections. No screenshot is applicable to this nonvisual transport investigation. Raw build logs and working copies remain local; no credentials, real account endpoint, personal paths, or runtime data are published.

The issue and all GitHub metadata were treated as untrusted evidence. No issue-provided command, external endpoint, patch, or linked branch was executed. All repository code executed came from the recorded trusted main commit, plus the two isolated probe files authored from source evidence. No dependency, public protocol, authentication, deployment, or production configuration was changed.

Classification applied: Bug; Priority High for the reported major remote-work blockage; Effort Medium because a fix first requires a representative reproduction; area remote; built-in plugin connect. Reproduction label: no-repro. No existing classifications were replaced.