#7021 · Pinned browser runtime truncates large piped results
Verdict: REPRODUCED · Root-cause confidence: high at the native stdout and BB runtime lifecycle boundaries. The exact implementation defect inside the native executable is not established.
1. TL;DR
The pinned DevBrowser executable can end a large JSON result before its closing quote when stdout is a pipe. BB receives that incomplete line, fails JSON parsing, and deliberately closes the session on that exception. A 48,000-character result and a follow-up command succeed, while 70,000- and 100,000-character results fail and leave the session unusable. The same 100,000-character native result is intact when stdout is a regular file, isolating the loss to native piped-output delivery rather than the BB server/daemon RPC transport. Two separate trusted checkouts reproduce this behavior.
2. Claims vs findings
| Claim | Status | Evidence |
|---|---|---|
| Large results cause an unterminated JSON error. | Verified | Both checkouts fail at 70,000 and 100,000 characters. The local error offset is 131072. |
| The session becomes unusable after the error. | Verified | A follow-up calculation succeeds after the 48,000-character control and is aborted after each malformed large result. The runtime catch closes its processes and removes its session directory. |
| Loss is always in 36,544-character units. | Unverified | Observed cutoffs here are 131,072 and 262,144 characters, not the reported unit. Nothing in the BB collector uses 36,544. The observations show truncated tails, not evidence of whole interior chunks being removed. |
| The threshold is an intentional BB 64–90 KB limit. | Not supported | The BB collector permits 512,000 bytes. A native 100,000-character result duplicates the string into value and data, producing a 200,038-character JSON line, plus a completion frame. |
| A 48 KB output cap avoids the observed failure. | Verified locally | The 48,000-character control is complete and its next command returns 42 in both runs. This is not a universal safe-size guarantee. |
| The public CLI on the originally reported release fails identically with a real browser. | Not rerun end-to-end | Testing uses current trusted main and the actual pinned native executable through the production runtime, not the original release or the public CLI. A protocol fixture replaces the browser connection only. |
3. Environment
- Trusted public repository: get-bb/bb; main commit
d060de8e30f3310417054a74510a774dd2909e2b, fetched again unchanged before publication. - Linux x86_64; Node v22.19.0; native DevBrowser 1.0.0-rc.4 installed with the repository installer, signature/provenance verification and pinned SHA-256 verification.
- Two fresh detached worktrees, named
baseandverify, at exactly the same commit. Only the authored diagnostic was added; production source was unchanged. - Fresh temporary data/session directories and a newly kernel-assigned loopback WebSocket port per run. No real BB core, user browser, credentials, providers, or runtime data was used.
- A Chrome launch was attempted, but the host lacks required system libraries (including libglib-2.0.so.0). No system dependency was added. The final diagnostic therefore uses a minimal CDP connection fixture returning no browser targets; it does not simulate the output producer, native daemon, pipe, parser, or runtime lifecycle.
4. Minimal reproduction
Copy the complete diagnostic source embedded in this section into plugins/browser-automation/issue-7021-repro.ts in a clean checkout of the recorded commit. It uses the already-declared ws dependency through the server package and the production runtime installer. It evaluates synthetic strings locally; it does not navigate to any website.
- Prepare the trusted checkout and normal build dependencies:
git fetch origin main git worktree add --detach /tmp/bb-7021-repro d060de8e30f3310417054a74510a774dd2909e2b cd /tmp/bb-7021-repro pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk pnpm exec turbo run build --filter=@get-bb/plugin-sdk pnpm exec turbo run build --filter=bb-plugin-browser-automation
- Copy the linked diagnostic into its stated location, then run:
RUN_DATA=$(mktemp -d /tmp/bb-7021-data-XXXXXX) cd plugins/browser-automation TSX_TSCONFIG_PATH=tsconfig.smoke.json node --import tsx issue-7021-repro.ts "$RUN_DATA"
- The diagnostic first warms the native daemon, compares repeated native pipe output to a regular-file control, then opens a new production runtime session for each payload size. Each payload is followed by
6 * 7. It is an observational diagnostic: exit zero means its probes completed, not that the bug is absent.
Expected: 70,000 and 100,000 characters arrive complete, with exit code 0, and follow-up runs return 42. Alternatively, a documented size error should not silently corrupt NDJSON.
Actual, first checkout (verbatim):
{"runtime":"1.0.0-rc.4","node":"v22.19.0","platform":"linux","arch":"x64"}
{"boundary":"native","sink":"pipe","length":131072,"lines":[{"length":131072,"prefix":"{\"type\":\"result\",\"value\":\"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz","suffix":"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz","error":"Unterminated string in JSON at position 131072 (line 1 column 131073)"}]}
{"boundary":"native","sink":"pipe","length":131072,"lines":[{"length":131072,"prefix":"{\"type\":\"result\",\"value\":\"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz","suffix":"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz","error":"Unterminated string in JSON at position 131072 (line 1 column 131073)"}]}
{"boundary":"native","sink":"pipe","length":131072,"lines":[{"length":131072,"prefix":"{\"type\":\"result\",\"value\":\"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz","suffix":"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz","error":"Unterminated string in JSON at position 131072 (line 1 column 131073)"}]}
{"boundary":"native","sink":"file","length":200083,"lines":[{"length":200038,"type":"result","valueLength":100000,"dataLength":100000},{"length":43,"type":"done"}]}
{"boundary":"native","sink":"pipe","length":131072,"lines":[{"length":131072,"prefix":"{\"type\":\"result\",\"value\":\"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz","suffix":"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz","error":"Unterminated string in JSON at position 131072 (line 1 column 131073)"}]}
{"boundary":"runtime","size":48000,"exitCode":0,"length":48000,"complete":true}
{"boundary":"follow-up","size":48000,"text":"42"}
{"boundary":"runtime","size":70000,"error":"Unterminated string in JSON at position 131072 (line 1 column 131073)"}
{"boundary":"follow-up","size":70000,"error":"This operation was aborted"}
{"boundary":"runtime","size":100000,"error":"Unterminated string in JSON at position 131072 (line 1 column 131073)"}
{"boundary":"follow-up","size":100000,"error":"This operation was aborted"}
{"boundary":"runtime","size":150000,"error":"Unterminated string in JSON at position 131072 (line 1 column 131073)"}
{"boundary":"follow-up","size":150000,"error":"This operation was aborted"}
{"boundary":"runtime","size":300000,"error":"Unterminated string in JSON at position 262144 (line 1 column 262145)"}
{"boundary":"follow-up","size":300000,"error":"This operation was aborted"}
The regular-file control preserves both 100,000-character string fields and the done frame. Four warmed native pipe invocations stop at 131,072 bytes, below BB's 512,000-byte guard.
Complete diagnostic source
import { mkdir, mkdtemp, open, readFile } from "node:fs/promises";
import { join } from "node:path";
import { createRequire } from "node:module";
import { spawn } from "node:child_process";
import { createRuntime, runtimeEnvironment } from "./runtime.js";
import { resolveRuntime } from "./runtime-pin.js";
import { execute, supervise } from "./process.js";
import { setTimeout as delay } from "node:timers/promises";
const root = process.argv[2]!;
await mkdir(root, { recursive: true });
const dataDir = join(root, "data");
const require = createRequire(new URL("../../apps/server/package.json", import.meta.url));
const { WebSocketServer } = require("ws");
const cdp = new WebSocketServer({ host: "127.0.0.1", port: 0 });
await new Promise<void>((resolve) => cdp.once("listening", resolve));
cdp.on("connection", (socket) => {
socket.on("message", (data) => {
const request = JSON.parse(data.toString());
const result = request.method === "Target.getBrowserContexts"
? { browserContextIds: [] }
: request.method === "Target.getTargets"
? { targetInfos: [] }
: request.method === "Browser.getVersion"
? { product: "Chrome/157.0.0.0", protocolVersion: "1.3", userAgent: "fixture", jsVersion: "0" }
: {};
socket.send(JSON.stringify({ id: request.id, result }));
});
});
const signal = AbortSignal.timeout(180_000);
const runtime = await resolveRuntime({ dataDir, signal });
console.log(JSON.stringify({ runtime: runtime.version, node: process.version, platform: process.platform, arch: process.arch }));
try {
const home = await mkdtemp(join(root, "native-"));
const env = runtimeEnvironment(home);
const daemon = supervise(runtime.binary, ["daemon"], env);
try {
while (true) {
signal.throwIfAborted();
try {
await readFile(join(home, "daemon.pid"));
break;
} catch {
await delay(25);
}
}
await execute(runtime.binary, ["--json", "--connect", "ws://127.0.0.1:" + cdp.address().port, "--quiet-page", "-e", "6 * 7"], env, signal);
for (const sink of ["pipe", "pipe", "pipe", "file", "pipe"]) {
const args = ["--json", "--connect", "ws://127.0.0.1:" + cdp.address().port, "--timeout", "15", "--quiet-page", "-e", '"z".repeat(100000)'];
let stdout: string;
if (sink === "pipe") {
stdout = await execute(runtime.binary, args, env, signal);
} else {
const path = join(root, "native-file.ndjson");
const file = await open(path, "w");
try {
const child = spawn(runtime.binary, args, { env, stdio: ["ignore", file.fd, "ignore"] });
await new Promise<void>((resolve, reject) => {
child.once("error", reject);
child.once("close", (code) => code === 0 ? resolve() : reject(new Error("native exit " + code)));
});
} finally {
await file.close();
}
stdout = await readFile(path, "utf8");
}
console.log(JSON.stringify({ boundary: "native", sink, length: stdout.length, lines: stdout.split("\n").filter(Boolean).map((line) => {
try {
const frame = JSON.parse(line);
return { length: line.length, type: frame.type, valueLength: frame.value?.length, dataLength: frame.data?.length };
} catch (error) {
return { length: line.length, prefix: line.slice(0, 60), suffix: line.slice(-30), error: error instanceof Error ? error.message : String(error) };
}
}) }));
}
} finally {
await daemon.close();
}
for (const size of [48_000, 70_000, 100_000, 150_000, 300_000]) {
const session = await createRuntime({ runtime, dataDir, tempDir: join(root, "sessions"), connectionUrl: "ws://127.0.0.1:" + cdp.address().port, signal });
try {
try {
const result = await session.run('"z".repeat(' + size + ')', 15_000, signal);
console.log(JSON.stringify({ boundary: "runtime", size, exitCode: result.exitCode, length: result.text.length, complete: result.text === "z".repeat(size) }));
} catch (error) {
console.log(JSON.stringify({ boundary: "runtime", size, error: error instanceof Error ? error.message : String(error) }));
}
try {
const result = await session.run("6 * 7", 15_000, signal);
console.log(JSON.stringify({ boundary: "follow-up", size, text: result.text }));
} catch (error) {
console.log(JSON.stringify({ boundary: "follow-up", size, error: error instanceof Error ? error.message : String(error) }));
}
} finally {
await session.close();
}
}
} finally {
for (const socket of cdp.clients) socket.terminate();
await new Promise<void>((resolve) => cdp.close(resolve));
}
5. Root cause
- The runtime pin selects DevBrowser 1.0.0-rc.4 and verifies the platform binary digest. The experiment uses that exact release, not an issue-supplied executable.
- The process collector launches stdout as a pipe, concatenates received UTF-8 chunks, and resolves only on child close. Its configured output guard is 512,000 bytes. In the failing native control only 131,072 ASCII bytes arrive, so this guard has not fired.
- The native pipe control ends inside a duplicated result string and contains no completion frame. Sending the same command to the same warmed daemon with a regular-file stdout descriptor yields a complete 200,038-character result line and a done frame. This isolates the defect to native piped-output delivery before BB's JSON decoder or any server RPC. A missing stdout drain at native process exit is a plausible explanation, not a verified native-source diagnosis.
- decodeOutput calls
JSON.parse(line), which correctly rejects the incomplete string. - close() aborts the session controller, closes its supervisors, and removes session storage. The run catch invokes it for every thrown error. The next queued run checks that aborted signal and fails with
This operation was aborted. The host run handler also closes on a runtime exception, explaining why a public session cannot simply retry.
process.ts: stdio: ["ignore", "pipe", "pipe"]
runtime.ts: const frame = frameSchema.parse(JSON.parse(line));
runtime.ts: catch (error) { await close(); throw error; }
Confidence is high for the native-output boundary and subsequent BB closure mechanism. Confidence in a specific native flush implementation defect is only medium without upstream source-level instrumentation. Exact observed byte cutoffs can vary with scheduling and pipe capacity.
6. Proposed fix and simple-fix decision
Repair native NDJSON output delivery so pending bytes are drained before process completion, validate both pipe and regular-file output on a warmed daemon, and publish a verified runtime release. Then update BB's pinned release and platform digests through the normal runtime release process. A runtime-level regression should verify an intact 100,000-character result and a successful subsequent command.
No PR opened: the verified producer defect is in the pinned external native runtime. Repairing that producer and adopting its release is outside this rule's one-subsystem, no-dependency/no-packaging-change simple-fix scope. Merely swallowing JSON errors or avoiding session closure does not recover lost output. A local file-spooling workaround would need a separate review of temporary-output ownership, cancellation and enforcement of the existing output guard; it is not treated as an automatically safe fix here.
No open linked PR appeared in either cross-reference metadata or the repository PR search. No production patch, fix branch, dependency change, or target-repository commit was made.
7. Verification
The same agent repeated the diagnostic in a second clean trusted checkout; this is a second clean run, not an independent review. The verify checkout was created at d060de8e30f3310417054a74510a774dd2909e2b, installed with the frozen lockfile, built its SDK and browser plugin using Turbo, and received an identical copy of the diagnostic. A byte comparison confirmed the scripts match, and git confirmed the production runtime/collector/pin were unchanged. The second run used verified-run rather than either first-run data directory and a new ephemeral fixture port.
Command (from the browser plugin directory, with a new temporary directory as the argument):
TSX_TSCONFIG_PATH=tsconfig.smoke.json node --import tsx issue-7021-repro.ts "$RUN_DATA"
Result: all four warmed pipe controls truncate; the regular-file control is intact; 48,000 characters and a follow-up succeed; 70,000 and 100,000 characters fail parsing and abort follow-ups. Higher-size offsets vary, so no universal chunk size or fixed threshold is claimed. No core conclusion required correction after the second run.
Second run (verbatim):
{"runtime":"1.0.0-rc.4","node":"v22.19.0","platform":"linux","arch":"x64"}
{"boundary":"native","sink":"pipe","length":131072,"lines":[{"length":131072,"prefix":"{\"type\":\"result\",\"value\":\"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz","suffix":"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz","error":"Unterminated string in JSON at position 131072 (line 1 column 131073)"}]}
{"boundary":"native","sink":"pipe","length":131072,"lines":[{"length":131072,"prefix":"{\"type\":\"result\",\"value\":\"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz","suffix":"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz","error":"Unterminated string in JSON at position 131072 (line 1 column 131073)"}]}
{"boundary":"native","sink":"pipe","length":131072,"lines":[{"length":131072,"prefix":"{\"type\":\"result\",\"value\":\"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz","suffix":"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz","error":"Unterminated string in JSON at position 131072 (line 1 column 131073)"}]}
{"boundary":"native","sink":"file","length":200083,"lines":[{"length":200038,"type":"result","valueLength":100000,"dataLength":100000},{"length":43,"type":"done"}]}
{"boundary":"native","sink":"pipe","length":131072,"lines":[{"length":131072,"prefix":"{\"type\":\"result\",\"value\":\"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz","suffix":"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz","error":"Unterminated string in JSON at position 131072 (line 1 column 131073)"}]}
{"boundary":"runtime","size":48000,"exitCode":0,"length":48000,"complete":true}
{"boundary":"follow-up","size":48000,"text":"42"}
{"boundary":"runtime","size":70000,"error":"Unterminated string in JSON at position 131072 (line 1 column 131073)"}
{"boundary":"follow-up","size":70000,"error":"This operation was aborted"}
{"boundary":"runtime","size":100000,"error":"Unterminated string in JSON at position 131072 (line 1 column 131073)"}
{"boundary":"follow-up","size":100000,"error":"This operation was aborted"}
{"boundary":"runtime","size":150000,"error":"Unterminated string in JSON at position 262144 (line 1 column 262145)"}
{"boundary":"follow-up","size":150000,"error":"This operation was aborted"}
{"boundary":"runtime","size":300000,"error":"Unterminated string in JSON at position 262144 (line 1 column 262145)"}
{"boundary":"follow-up","size":300000,"error":"This operation was aborted"}
Existing owner-boundary suites also pass:
pnpm exec turbo run test --filter=bb-plugin-browser-automation -- process.test.ts runtime.test.ts Test Files 2 passed (2) Tests 11 passed (11)
8. Related issues
No duplicate was established by searches for the browser automation area and JSON parse symptom. Other browser installation/desktop-session reports are not evidence of this pipe-output defect. The issue had no comments or linked PRs when investigated.
9. Appendix and limitations
- Both raw diagnostic outputs and the complete repeatable diagnostic are embedded above. Following this public report repository's publication policy, no separate scripts or raw log files are committed.
- Preparation used git fetch/worktree, frozen pnpm install, and Turbo builds. An initial unrestricted build encountered an existing cold-build SDK ordering failure in the GitHub plugin. Building the SDK before the affected plugin resolved its missing-dist prerequisite; no repository code was changed to repair unrelated build ordering.
- GitHub metadata and classification reads used gh API/issue/PR queries; all classification and report-label writes use the supplied SlopCop write command. No issue-supplied code, command, link, branch or attachment was executed or fetched.
- All source links were checked against the recorded base with git show. The reproduction is at the actual native-output and production-runtime boundary, not a full public CLI/server/daemon/browser journey. No browser rendering or screenshot claim is made.
- The original historical error offsets and original release environment remain unverified. A successful 48 KB control is not proof that a 48 KB cap is universally safe.
> AGENT GENERATED