The best way to control Claude Code, Codex and more from any computer or phone
fix(desktop): an emptied browser cookie jar imports as empty instead of failing (#34698)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Julio Saldaña committed
Nov 14, 2026 at 13:36 UTC
47a8f2ba92370b9df24be1591c1ed555df344264
3 files changed
+33
apps/desktop/src/preview/BrowserImport/ChromiumCookies.test.ts
+23
@@ -358,6 +358,29 @@ describe("readChromiumCookieDatabase", () => {
358
}).pipe(Effect.provide(NodeServices.layer)),
359
);
360
361
+ it.effect("reads a cookie database the browser has emptied as having no cookies", () =>
362
+ Effect.gen(function* () {
363
+ const fileSystem = yield* FileSystem.FileSystem;
364
+ const directory = yield* fileSystem.makeTempDirectoryScoped({
365
+ prefix: "t3code-chromium-cookies-",
366
+ });
367
+ const filename = `${directory}/Cookies`;
368
+ yield* Effect.gen(function* () {
369
+ const sql = yield* SqlClient.SqlClient;
370
+ yield* sql`create table scratch (id integer)`;
371
+ yield* sql`drop table scratch`;
372
+ }).pipe(Effect.provide(NodeSqliteClient.layer({ filename })));
373
+
374
+ const result = yield* readChromiumCookieDatabase(
375
+ filename,
376
+ { cbcV10: Buffer.from("0123456789abcdef") },
377
+ "darwin",
378
+ );
379
+
380
+ expect(result).toEqual({ cookies: [], undecryptable: 0, undecryptableHosts: [] });
381
+ }).pipe(Effect.provide(NodeServices.layer), Effect.scoped),
382
+ );
383
+
384
it.effect("skips partitioned cookies without breaking pre-CHIPS schemas", () =>
385
Effect.gen(function* () {
386
const fileSystem = yield* FileSystem.FileSystem;
apps/desktop/src/preview/BrowserImport/ChromiumCookies.ts
+4
@@ -181,6 +181,10 @@ export const readChromiumCookieDatabase = Effect.fn("ChromiumCookies.readChromiu
181
function* (snapshotPath: string, keys: ChromiumKeyMaterial, platform: NodeJS.Platform) {
182
const result = yield* Effect.gen(function* () {
183
const sql = yield* SqlClient.SqlClient;
184
+ // Chromium razes a damaged jar to a file with no tables and rebuilds it on its next write.
185
+ const tables =
186
+ yield* sql`select 1 from sqlite_master where type = 'table' and name = 'cookies'`;
187
+ if (tables.length === 0) return { rows: [], schemaVersion: 0 };
188
const schemaVersion = yield* sql`select value from meta where key = 'version' limit 1`.pipe(
189
Effect.flatMap(decodeSchemaVersion),
190
Effect.map(([row]) => row.value),
apps/desktop/src/preview/BrowserImport/Sources.ts
+6
@@ -345,6 +345,12 @@ const countProfileCookies = Effect.fnUntraced(function* (
345
if (database === undefined) return undefined;
346
return yield* Effect.gen(function* () {
347
const sql = yield* SqlClient.SqlClient;
348
+ // readChromiumCookieDatabase imports a razed jar as empty; Firefox has no such reader guard.
349
+ if (definition.engine !== "firefox") {
350
+ const tables =
351
+ yield* sql`select 1 from sqlite_master where type = 'table' and name = 'cookies'`;
352
+ if (tables.length === 0) return 0;
353
+ }
354
const rows =
355
definition.engine === "firefox"
356
? yield* sql`select count(*) as count from moz_cookies where originAttributes = ''`