#1093·obscura

IndexedDB reports successful writes but loses data between transactions

Author: jorgensandhaugCreated Sep 26, 2026Updated Sep 26, 2026

Summary

IndexedDB put() reports success, but a subsequent transaction on the same database connection reads no value. The shim also fires transaction complete before the write request's success, and open() never fires upgradeneeded. This loses state in ordinary same-page flows without navigation or process restart. Found during OpenGeni browser engine compatibility testing with a synthetic local page.

Before you start

  • I searched existing issues. #678 concerns sessionStorage across navigation/targets; #694 concerns storage across CLI invocations. This reproduces within one page and connection.
  • Tested on a render-enabled post-v0.2.3 source build; current main has the same IndexedDB shim.
  • This is not a security vulnerability.

Environment

  • Obscura: render-enabled Linux x86_64 binary built from 578fab10fdd02a047f3d76cb5ea3b218a649efd9 (v0.2.3-5-g578fab1), stealth off.
  • Chromium control: Chrome for Testing 150.0.7871.46, Linux x86_64.
  • CDP server with Puppeteer Core 25.12.0; Bun 1.4.0 runs the offline fixture.
  • Affected area: JavaScript/DOM IndexedDB behavior.

Reproduction

Save the following as repro.ts, then run bun add [email protected] and bun repro.ts /path/to/obscura /path/to/chrome. It serves a blank local page and runs the same code in both engines. No external site or account is involved.

typescript
import puppeteer from "puppeteer-core";

const [obscuraBin, chromiumBin] = process.argv.slice(2);
if (!obscuraBin || !chromiumBin) throw new Error("usage: bun repro.ts OBSCURA_BIN CHROME_BIN");

const server = Bun.serve({
  hostname: "127.0.0.1",
  port: 0,
  fetch: () => new Response("<!doctype html><title>IndexedDB reproduction</title>", {
    headers: { "content-type": "text/html" },
  }),
});
const pause = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));

async function probe(engine: "obscura" | "chromium") {
  let browser: Awaited<ReturnType<typeof puppeteer.connect>> | undefined;
  let process: ReturnType<typeof Bun.spawn> | undefined;
  try {
    if (engine === "obscura") {
      process = Bun.spawn([obscuraBin!, "serve", "--port", "9499", "--allow-private-network"], {
        stdout: "ignore",
        stderr: "ignore",
      });
      let endpoint = "";
      for (let attempt = 0; attempt < 100 && !endpoint; attempt++) {
        endpoint = await fetch("http://127.0.0.1:9499/json/version")
          .then((response) => response.json())
          .then((value) => value.webSocketDebuggerUrl ?? "")
          .catch(() => "");
        if (!endpoint) await pause(50);
      }
      if (!endpoint) throw new Error("Obscura CDP did not start");
      browser = await puppeteer.connect({ browserWSEndpoint: endpoint, protocolTimeout: 10_000 });
    } else {
      browser = await puppeteer.launch({
        executablePath: chromiumBin!,
        headless: true,
        args: ["--no-sandbox", "--disable-dev-shm-usage"],
      });
    }

    const context = await browser.createBrowserContext();
    const page = await context.newPage();
    await page.goto(`http://127.0.0.1:${server.port}/`, { waitUntil: "domcontentloaded" });
    const result = await page.evaluate(async () => {
      const events: string[] = [];
      const request = indexedDB.open("minimal", 1);
      const database = await new Promise<IDBDatabase>((resolve, reject) => {
        request.onupgradeneeded = () => {
          events.push("upgradeneeded");
          request.result.createObjectStore("items");
        };
        request.onsuccess = () => { events.push("open-success"); resolve(request.result); };
        request.onerror = () => reject(request.error);
      });
      const transaction = database.transaction("items", "readwrite");
      const write = transaction.objectStore("items").put("stored-value", "key");
      await new Promise<void>((resolve, reject) => {
        write.onsuccess = () => events.push("put-success");
        transaction.oncomplete = () => { events.push("write-transaction-complete"); resolve(); };
        transaction.onerror = () => reject(transaction.error);
      });
      const read = database.transaction("items", "readonly").objectStore("items").get("key");
      const value = await new Promise<unknown>((resolve, reject) => {
        read.onsuccess = () => { events.push("get-success"); resolve(read.result ?? null); };
        read.onerror = () => reject(read.error);
      });
      return { events, value };
    });
    console.log(JSON.stringify({ engine, result }));
    await context.close();
  } finally {
    if (engine === "chromium") await browser?.close();
    else {
      await browser?.disconnect();
      process?.kill("SIGTERM");
      if (process) await process.exited;
    }
  }
}

try {
  await probe("chromium");
  await probe("obscura");
} finally {
  server.stop(true);
}

Expected

The upgrade event creates items; put succeeds before its transaction completes; a new readonly transaction returns stored-value.

Chromium: ["upgradeneeded","open-success","put-success","write-transaction-complete","get-success"], value="stored-value"

Actual

Obscura: ["open-success","write-transaction-complete","put-success","get-success"], value=null

The exact differential repeated in a six-context synthetic workload. The apparent successful write is discarded because crates/obscura-js/js/bootstrap.js creates fresh object-store Maps for every transaction. The same file schedules complete ahead of the request callback and does not implement upgradeneeded. A fix needs storage scoped by browser context and origin, plus transaction event ordering; retaining one JS Map inside the current realm alone would not address navigation or context isolation.