#7661 · Cookie lifetime at the desktop persistence boundary
Trusted base: 64c272a16e68ddac62b3303014c8f95032815d3c. Verdict: PARTIALLY REPRODUCED · Root-cause confidence: medium.
1. TL;DR
The import path preserves the distinction between temporary session cookies and cookies with an explicit expiration. A real synthetic Chromium database passed through the actual reader and writer produces a session-cookie write without an expiration, alongside an unchanged persistent expiration, and invokes a disk flush. Electron’s installed API declarations document that cookies without an expiration are not retained between sessions; the desktop Browser uses a persistent partition without a separate session-cookie restoration path in the inspected code. This supports the proposed restart mechanism but does not demonstrate a live sign-out. Two clean checkouts produced the same boundary results, while both attempts to launch the real Electron restart test stopped before application code because this host lacks libglib-2.0.so.0.
2. Claims vs findings
| Claim | Status | Evidence |
|---|---|---|
| Zero Chromium expiry remains a session cookie at import. | Verified at the boundary | Actual SQLite reader and writer emit no expiration property for the synthetic session control in both checkouts. |
| Persistent expiry is not arbitrarily shortened. | Verified for the control | The synthetic persistent control retains its original Unix expiry exactly. |
| A flush already runs after successful imports. | Verified | The actual writer makes one flush call after two successful writes; the recording sink does not model storage. |
| The desktop Browser uses a persistent partition. | Verified in source | The manager defaults to persist:bb-browser and uses session.fromPartition(partition). |
| Session cookies disappear while persistent cookies remain after restart. | Runtime unverified | Installed Electron API documentation supports this prediction. Neither launch reached the seed phase. |
| Chrome restores the same data, or an affected website loses its sign-in. | Unverified | No Chrome UI, real account, source profile, website navigation, or personal cookie data was used. |
| Sign-outs while bb stays running share this cause. | Not established | This investigation only checks import lifetime and the proposed restart boundary. |
3. Environment
- Public repository:
get-bb/bb; both detached checkouts use the exact trusted base above, also current remote main when checked. - Linux x86-64 container, kernel
4.19.0-gvisor; Nodev22.19.0; pnpm9.15.0; pinned Electron44.10.2. - Normal frozen install and
pnpm exec turbo run build --filter=@bb/desktopsucceed in both checkouts (64 tasks each; second build uses the existing cache). - Existing import suite: 36 tests pass in each checkout; second suite was forced to execute rather than replay cache.
- No app server, host daemon, provider turn, user instance, listening port, or browser automation session was started. Provider versions are not applicable.
- Each diagnostic creates its own temporary directory. The runtime test uses a fresh profile under that directory and attempts headless Electron without a sandbox solely inside this disposable container. These flags are not a proposed product configuration. Both diagnostics remove their temporary directories.
4. Minimal reproduction
The boundary diagnostic is executable evidence about the actual import implementation, not a substitute for a successful restart regression. Its recording cookie sink only records arguments and flush calls; it does not pretend to persist cookies. The standalone Electron test is also provided but is blocked on this host.
- Create a clean checkout from trusted main, record its commit, and install/build its normal dependencies. For the exact reported base, detach at
64c272a16e68ddac62b3303014c8f95032815d3cbefore running the install.git clone https://github.com/get-bb/bb.git checkout-a cd checkout-a git checkout --detach 64c272a16e68ddac62b3303014c8f95032815d3c pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build --filter=@bb/desktop pnpm exec turbo run test --filter=@bb/desktop -- test/browser-import.test.ts
- Download the three linked reproduction files into one directory outside the checkout. Run the import boundary diagnostic against an absolute checkout path.
node boundary.mjs /absolute/path/to/checkout-a
Expected and actual in both checkouts (verbatim substantive output):{"imported":2,"sessionExpirationOmitted":true,"persistentExpirationPreserved":true,"flushes":1} BOUNDARY PASS: real Chromium reader and writer; recording sink only, no Electron persistence simulatedThis exits 0. It shows correct import semantics, not observed loss. - Attempt the real two-process restart regression after the existing test task has installed the pinned Electron binary.
node run.mjs /absolute/path/to/checkout-a
The runner bundles the real partition constant and actual import functions. In a working Electron environment the seed phase imports two synthetic cookies, checks their lifetime flags, flushes, and quits. A second process reopens the same profile and asserts that both controls remain; persistent loss invalidates the test, while session-only loss fails the target assertion. On this host the actual result is instead (checkout prefix normalized):<checkout-a>/node_modules/.pnpm/electron@44.10.2/node_modules/electron/dist/electron: error while loading shared libraries: libglib-2.0.so.0: cannot open shared object file: No such file or directory phase=seed exit=127 signal=null
No seed result, restart result, or expected regression failure was observed. Exit 127 is an environment failure, not evidence that the product bug reproduced.
boundary.mjs
import assert from "node:assert/strict";
import { createRequire } from "node:module";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { DatabaseSync } from "node:sqlite";
const checkout = resolve(process.argv[2]);
const requireDesktop = createRequire(join(checkout, "apps/desktop/package.json"));
const { build } = requireDesktop("esbuild");
const temporary = mkdtempSync(join(tmpdir(), "bb-7661-boundary-"));
const database = new DatabaseSync(":memory:");
try {
const bundle = join(temporary, "production.cjs");
await build({
stdin: {
contents: [
`export { readChromiumCookieDatabase } from ${JSON.stringify(join(checkout, "apps/desktop/src/browser-import/chromium-cookies.ts"))};`,
`export { writeCookies } from ${JSON.stringify(join(checkout, "apps/desktop/src/browser-import/browser-import.ts"))};`,
].join("\n"),
resolveDir: checkout,
},
outfile: bundle,
bundle: true,
platform: "node",
format: "cjs",
conditions: ["source"],
legalComments: "none",
});
const { readChromiumCookieDatabase, writeCookies } = requireDesktop(bundle);
database.exec("CREATE TABLE meta (key TEXT, value TEXT); INSERT INTO meta VALUES ('version', '23'); CREATE TABLE cookies (host_key TEXT, name TEXT, value TEXT, encrypted_value BLOB, path TEXT, expires_utc INTEGER, is_secure INTEGER, is_httponly INTEGER, samesite INTEGER, top_frame_site_key TEXT)");
const insert = database.prepare("INSERT INTO cookies VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
const expiration = Math.floor(Date.now() / 1000) + 3600;
insert.run("cookie-probe.invalid", "transient_control", "synthetic", Buffer.alloc(0), "/", 0, 1, 1, 1, "");
insert.run("cookie-probe.invalid", "durable_control", "synthetic", Buffer.alloc(0), "/", (11644473600 + expiration) * 1000000, 1, 1, 1, "");
const decoded = readChromiumCookieDatabase(database, {});
assert.equal(decoded.cookies.length, 2);
assert.equal(decoded.undecryptable, 0);
const writes = [];
let flushes = 0;
const outcome = await writeCookies({ cookies: {
set: async (details) => { writes.push(details); },
flushStore: async () => { flushes += 1; },
} }, decoded);
assert.equal(outcome.imported, 2);
assert.equal(outcome.skipped, 0);
assert.equal(writes.length, 2);
assert.equal(Object.hasOwn(writes.find((cookie) => cookie.name === "transient_control"), "expirationDate"), false);
assert.equal(writes.find((cookie) => cookie.name === "durable_control").expirationDate, expiration);
assert.equal(flushes, 1);
console.log(JSON.stringify({ imported: outcome.imported, sessionExpirationOmitted: true, persistentExpirationPreserved: true, flushes }));
console.log("BOUNDARY PASS: real Chromium reader and writer; recording sink only, no Electron persistence simulated");
} finally {
database.close();
rmSync(temporary, { recursive: true, force: true });
}
run.mjs
import { spawnSync } from "node:child_process";
import { createRequire } from "node:module";
import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
const checkout = resolve(process.argv[2]);
const requireDesktop = createRequire(join(checkout, "apps/desktop/package.json"));
const { build } = requireDesktop("esbuild");
const electron = requireDesktop("electron");
const artifactDirectory = dirname(fileURLToPath(import.meta.url));
const temporary = mkdtempSync(join(tmpdir(), "bb-7661-cookie-"));
const bundle = join(temporary, "production.cjs");
const environment = { ...process.env };
delete environment.ELECTRON_RUN_AS_NODE;
try {
mkdirSync(join(temporary, "profile"));
await build({
stdin: {
contents: [
`export { BB_BROWSER_PARTITION } from ${JSON.stringify(join(checkout, "apps/desktop/src/desktop-browser-view.ts"))};`,
`export { readChromiumCookieDatabase } from ${JSON.stringify(join(checkout, "apps/desktop/src/browser-import/chromium-cookies.ts"))};`,
`export { writeCookies } from ${JSON.stringify(join(checkout, "apps/desktop/src/browser-import/browser-import.ts"))};`,
].join("\n"),
resolveDir: checkout,
},
outfile: bundle,
bundle: true,
platform: "node",
format: "cjs",
conditions: ["source"],
external: ["electron"],
legalComments: "none",
});
for (const phase of ["seed", "verify"]) {
const child = spawnSync(electron, [
"--no-sandbox",
"--ozone-platform=headless",
"--disable-gpu",
join(artifactDirectory, "restart.cjs"),
phase,
join(temporary, "profile"),
bundle,
], { env: environment, encoding: "utf8", timeout: 30000 });
process.stdout.write(child.stdout ?? "");
process.stderr.write(child.stderr ?? "");
console.log(`phase=${phase} exit=${child.status} signal=${child.signal}`);
if (child.error) throw child.error;
if (child.status !== 0) {
process.exitCode = child.status ?? 2;
break;
}
}
} finally {
rmSync(temporary, { recursive: true, force: true });
}
restart.cjs
const assert = require("node:assert/strict");
const { DatabaseSync } = require("node:sqlite");
const { app, session } = require("electron");
const { BB_BROWSER_PARTITION, readChromiumCookieDatabase, writeCookies } = require(process.argv[4]);
const phase = process.argv[2];
app.setPath("userData", process.argv[3]);
app.disableHardwareAcceleration();
app.whenReady().then(async () => {
const browserSession = session.fromPartition(BB_BROWSER_PARTITION);
const filter = { url: "https://cookie-probe.invalid/" };
if (phase === "seed") {
const database = new DatabaseSync(":memory:");
database.exec("CREATE TABLE meta (key TEXT, value TEXT); INSERT INTO meta VALUES ('version', '23'); CREATE TABLE cookies (host_key TEXT, name TEXT, value TEXT, encrypted_value BLOB, path TEXT, expires_utc INTEGER, is_secure INTEGER, is_httponly INTEGER, samesite INTEGER, top_frame_site_key TEXT)");
const insert = database.prepare("INSERT INTO cookies VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
const future = (11644473600 + Math.floor(Date.now() / 1000) + 3600) * 1000000;
insert.run("cookie-probe.invalid", "transient_control", "synthetic", Buffer.alloc(0), "/", 0, 1, 1, 1, "");
insert.run("cookie-probe.invalid", "durable_control", "synthetic", Buffer.alloc(0), "/", future, 1, 1, 1, "");
const read = readChromiumCookieDatabase(database, {});
database.close();
assert.equal(read.cookies.length, 2);
assert.equal(read.cookies.find((cookie) => cookie.name === "transient_control").expirationDate, undefined);
const outcome = await writeCookies(browserSession, read);
assert.equal(outcome.imported, 2);
assert.equal(outcome.skipped, 0);
const cookies = await browserSession.cookies.get(filter);
assert.equal(cookies.length, 2);
assert.equal(cookies.find((cookie) => cookie.name === "transient_control").session, true);
assert.equal(cookies.find((cookie) => cookie.name === "durable_control").session, false);
console.log(JSON.stringify({ phase, partition: BB_BROWSER_PARTITION, imported: outcome.imported, cookies: cookies.map(({ name, session }) => ({ name, session })) }));
} else if (phase === "verify") {
const cookies = await browserSession.cookies.get(filter);
const persistentSurvived = cookies.some((cookie) => cookie.name === "durable_control");
const sessionSurvived = cookies.some((cookie) => cookie.name === "transient_control");
console.log(JSON.stringify({ phase, persistentSurvived, sessionSurvived }));
assert.ok(persistentSurvived, "Persistent control did not survive; restart reproduction is invalid");
assert.ok(sessionSurvived, "Imported session cookie disappeared after process restart");
} else {
throw new Error("Unexpected phase");
}
app.quit();
}).catch((error) => {
console.error(error.message);
app.exit(1);
});
5. Root cause
The verified portion is an import-to-lifetime contract, not an expiry conversion error. Chromium expiry conversion maps zero expiry to absence, and the reader’s output carries it through. The writer then intentionally omits the expiration property:
...(cookie.expirationDate === undefined
? {}
: { expirationDate: cookie.expirationDate })
Successful imports already flush. Flushing is a storage operation, not an instruction to change cookie lifetime. The installed electron@44.10.2/electron.d.ts CookiesSetDetails.expirationDate declaration (lines 22031–22036) explicitly documents that omission makes a session cookie that is not retained between sessions. That declaration is inspected local dependency evidence; Electron’s native persistence flags were not independently inspected or exercised here.
The partition constant is persist:bb-browser. The manager chooses that default, and creates the session with fromPartition. The import handler supplies the manager’s session. Source inspection of these paths found no separate session-cookie snapshot/restore mechanism. Therefore a persistent partition alone does not address the documented session-cookie lifetime. This mechanism is a supported explanation for the restart report, but its runtime consequence and Chrome comparison remain unverified.
6. Proposed fix and safety gate
First run the supplied Electron regression on a host with the existing runtime prerequisites and a disposable profile. It should distinguish missing session cookies from lost persistent storage before any repair is attempted. If confirmed, decide the intended desktop restoration policy, then design scoped encrypted persistence with restoration before navigation and durable deletion/replacement handling. Test logout, expiration, replacements, normal exit and any supported crash recovery; a flush-only change would not change the lifetime contract.
No product patch or pull request is safe under this rule. Restart loss was not reproduced. Also, implementing durable session-cookie retention introduces stored authentication-bearing data and needs a product/security persistence decision, independently failing the simple-fix restrictions. No production changes, branch, dependency, or fix commit was created. No open pull request was found in the issue cross-reference metadata or an open-PR search for the numeric issue.
7. Verification
The same agent repeated the checks in a second new detached checkout, checkout-b, at 64c272a16e68ddac62b3303014c8f95032815d3c. This is a second clean run, not an independent reviewer. The production source remained unchanged in both checkouts. The second run used new diagnostic temporary directories and did not reuse profile data.
pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build --filter=@bb/desktop pnpm exec turbo run test --force --filter=@bb/desktop -- test/browser-import.test.ts node boundary.mjs /absolute/path/to/checkout-b node run.mjs /absolute/path/to/checkout-b
Results: build succeeds, 36 existing tests pass, boundary diagnostic exits 0 with the same substantive output, Electron again exits 127 before seed because the same shared library is missing. The final report is deliberately PARTIALLY REPRODUCED with medium confidence, rather than claiming a successful restart reproduction. verified: true in the publisher summary means this limited verdict was checked twice, not that live restart loss was confirmed.
8. Related issues
Read-only repository metadata places #5305 in headless automation profile persistence and #6314 in a proposed browser login store. Neither title establishes an implemented fix for this desktop cookie-lifetime path.
9. Appendix and artifacts
This is a nonvisual lifetime investigation, so no screenshots were fabricated. All values are synthetic. No external issue-supplied URL, script, patch, or branch was fetched or executed. Issue instructions were treated as untrusted data and ignored. Repository visibility was checked before publication.
Diagnostic logs normalize only local checkout prefixes; build/install logs remain local because they contain unrelated absolute paths. Relevant commands also included read-only issue/property/label/PR metadata, git fetch origin main, source inspection, clean-worktree checks and git diff --check. Classification writes use the SlopCop identity. No real application data was accessed.
- First boundary log · Second boundary log
- First runtime attempt · Second runtime attempt
- Build and test results · Installed Electron contract excerpt
> AGENT GENERATED