Skip to content

OPFSCoopSyncVFS: concurrent migrations on a fresh OPFS file hang forever and poison the lock file #341

Open

Description

@markalanhayton

Summary

With OPFSCoopSyncVFS, multiple connections writing to the same fresh OPFS file can hang forever, and the hang leaves the lock file poisoned: afterwards, even a brand-new connection cannot open the database. Reproduced deterministically (4/4 runs) in Chromium against both 1.7.2 and 2.0.2.

Repro (self-contained, ~40 lines)

mkdir repro && cd repro
npm i @journeyapps/[email protected] playwright
# save the script below as repro.mjs, then:
node repro.mjs
// Four module workers open the same fresh OPFS file and migrate it
// concurrently. Expected: all four settle (success or SQLITE_BUSY).
// Observed: nothing settles within 20s (RESULT: HANG:0); the lock
// file is left poisoned -- a fresh connection can no longer open it.
import { createServer } from 'node:http';
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
import { chromium } from 'playwright';

const PORT = 8765;
const WA = join(process.cwd(), 'node_modules', '@journeyapps', 'wa-sqlite');

const WORKER_SRC = `
  import SQLiteESMFactory from '/node_modules/@journeyapps/wa-sqlite/dist/wa-sqlite.mjs';
  import * as SQLite from '/node_modules/@journeyapps/wa-sqlite/src/sqlite-api.js';
  import { OPFSCoopSyncVFS } from '/node_modules/@journeyapps/wa-sqlite/src/examples/OPFSCoopSyncVFS.js';
  import { SQLITE_OPEN_READWRITE, SQLITE_OPEN_CREATE } from '/node_modules/@journeyapps/wa-sqlite/src/sqlite-constants.js';
  const module = await SQLiteESMFactory({ locateFile: (f) => '/node_modules/@journeyapps/wa-sqlite/dist/' + f });
  const sqlite3 = SQLite.Factory(module);
  const vfs = await OPFSCoopSyncVFS.create('opfs', module);
  sqlite3.vfs_register(vfs, true);
  self.onmessage = async (ev) => {
    const { id, filename } = ev.data;
    try {
      const db = await sqlite3.open_v2(filename, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE);
      await sqlite3.exec(db, 'CREATE TABLE t (i INTEGER)');
      await sqlite3.exec(db, 'BEGIN');
      for (let i = 0; i < 200; i++) await sqlite3.exec(db, 'INSERT INTO t (i) VALUES (' + i + ')');
      await sqlite3.exec(db, 'COMMIT');
      self.postMessage({ id, status: 'ok' });
    } catch (e) {
      self.postMessage({ id, status: 'error', message: String(e && e.message || e) });
    }
  };
`;

const PAGE = `<!DOCTYPE html>
<html><body><script type="module">
const filename = 'repro-' + Date.now() + '.db';
const workers = [0, 1, 2, 3].map((id) => {
  const w = new Worker('/worker.mjs', { type: 'module' });
  w.postMessage({ id, filename });
  return w;
});
const results = new Array(4).fill(null);
const deadline = setTimeout(() => {
  const done = results.filter((r) => r !== null).length;
  document.body.dataset.result = 'HANG:' + done;
}, 20000);
workers.forEach((w) => {
  w.onmessage = (ev) => {
    if (ev.data.status === 'error') {
      document.body.dataset.result = 'WORKER_ERROR:' + ev.data.message;
      return;
    }
    results[ev.data.id] = ev.data.status;
    if (results.every((r) => r !== null)) {
      clearTimeout(deadline);
      document.body.dataset.result = 'DONE:' + results.join(',');
    }
  };
});
</script></body></html>`;

const server = createServer(async (req, res) => {
  const url = new URL(req.url, 'http://127.0.0.1:' + PORT);
  res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
  res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp');
  if (url.pathname === '/') { res.end(PAGE); return; }
  if (url.pathname === '/worker.mjs') { res.setHeader('Content-Type', 'text/javascript'); res.end(WORKER_SRC); return; }
  if (url.pathname.startsWith('/node_modules/')) {
    try {
      const buf = await readFile(join(WA, url.pathname.slice('/node_modules/@journeyapps/wa-sqlite/'.length)));
      const ext = url.pathname.split('.').pop();
      res.setHeader('Content-Type', ext === 'wasm' ? 'application/wasm' : ext === 'mjs' || ext === 'js' ? 'text/javascript' : 'application/octet-stream');
      res.end(buf); return;
    } catch { res.statusCode = 404; res.end('nf'); return; }
  }
  res.statusCode = 404; res.end('nf');
});
await new Promise((r) => server.listen(PORT, '127.0.0.1', r));

const browser = await chromium.launch();
try {
  const page = await browser.newPage();
  await page.goto('http://127.0.0.1:' + PORT + '/', { waitUntil: 'domcontentloaded' });
  await page.waitForFunction(() => document.body.dataset.result, undefined, { timeout: 45000 });
  const result = await page.evaluate(() => document.body.dataset.result);
  console.log('RESULT:', result);
  if (result.startsWith('HANG')) { console.error('REPRODUCED: hang + poisoned lock file.'); process.exit(1); }
} finally { await browser.close(); server.close(); }

Observed behavior

  • Hang (deterministic): all four connections complete their WASM init, then nothing settles within 20s — the losers and the winner alike. In the repo's deeper tracing (1.7.2), the losers got instant SQLITE_BUSY ("database is locked") on their first write and the winner hung at its first write inside its own transaction; the same shape reproduces on 2.0.2.
  • Poisoned lock file (persistent): after the hang, a fresh connection cannot even complete open_v2 on the same file. The state is file-level, not connection-level — it survives the hung connections being closed, and persists until browser storage is cleared.
  • busy_timeout does not help: with PRAGMA busy_timeout = 5000, the losers wait the FULL window before aborting (the busy retry granularity is the whole timeout — a loser waited 5s while the winner had finished in 18ms) and the winner still hangs: its lock acquisition BLOCKS inside the VFS, invisible to SQLite's busy handler. journal_mode = WAL reduced but did not eliminate the hang.
  • Established files are fine: the same concurrent-write shape against an established file (created + migrated once, then two connections bursting overlapping transactions) settled cleanly in 1280/1280 transactions across 17 runs. The defect is specific to the fresh-file multi-writer phase (concurrent first-creation/migration).

Expected behavior

SQLite's documented concurrency contract: overlapping writers either serialize through the lock queue or fail with an honest SQLITE_BUSY — never a permanent hang, and never a state where the file cannot be opened again.

Environment

  • @journeyapps/wa-sqlite 1.7.2 and 2.0.2 (both tested; repro above pins 2.0.2)
  • Chromium headless shell 151 (Playwright), also reproduced on Chromium 149
  • Cross-origin isolated page (COOP/COEP) with OPFS, Chromium on Linux and Windows

Activity

  1. rhashimoto commented on Aug 12, 2026

    @rhashimoto
    Owner

    It's great to get a test case! I'd like to ask you to modify it to use this project (which is not on npm) instead of the @journeyapps/wa-sqlite fork and verify that the hang still occurs. That will make it easier for me to investigate.

  2. added
    response requested
    on Aug 22, 2026
  3. lalexdotcom commented on Sep 16, 2026

    @lalexdotcom
    Contributor

    Reading through the open issues after opening #347, this one looked like the
    same root cause seen from the other end — and it is. Here is the reproduction
    against this repository that you asked for, what a trace says is actually
    deadlocking, and one thing about the script above that is worth knowing before
    anyone spends time on it.

    The script in the issue cannot report anything but a hang

    Its workers use top-level await (await SQLiteESMFactory(...)), and the page
    posts their task immediately, at construction. A message posted before a module
    worker has finished evaluating is dropped, not queued — measured on both
    Chromium 151 and Firefox 153: the worker installs self.onmessage afterwards,
    and nothing is ever delivered to it.

    Instrumented, with the worker announcing each stage:

    worker-top
    imports-done
    factory-done
    vfs-ready
    handler-installed
              <- the page's message was posted before this, and is gone
    

    So every run reports HANG:0 — all four workers finish their WASM init and
    nothing settles — whatever the VFS does. That is the same shape @markalanhayton
    describes, so I suspect the posted script never exercised the bug, even though
    the bug is real: it reproduces reliably once the workers are handed their work
    after they are ready.

    Reproduction against this repo

    No fork and no build — dist/ is committed, so this needs only a checkout and
    Playwright. Save it as repro-341.mjs at the root of a wa-sqlite checkout:

    npm i playwright
    node repro-341.mjs 30
    
    repro-341.mjs
    // Reproduction for https://github.com/rhashimoto/wa-sqlite/issues/341, against
    // this repository rather than the @journeyapps fork.
    //
    //   npm i playwright        (or: yarn add -D playwright)
    //   node repro-341.mjs [runs]
    //
    // Run it from the root of a wa-sqlite checkout: dist/ is committed, so nothing
    // has to be built.
    //
    // Four module workers open the same fresh OPFS file and migrate it
    // concurrently. Expected: all four settle, with success or SQLITE_BUSY.
    // Observed on master: some runs never settle.
    //
    // Two deviations from the script in the issue, both noted where they appear:
    // the workers announce themselves before being given work, and CREATE TABLE is
    // IF NOT EXISTS.
    //
    // After a hang the page is closed -- which terminates the hung workers and
    // releases their access handles -- and one fresh connection then runs the same
    // workload on the same file in the same browser context, to test the
    // "poisoned lock file" part of the report.
    import { createServer } from 'node:http';
    import { readFile } from 'node:fs/promises';
    import { join, extname, normalize } from 'node:path';
    import { chromium } from 'playwright';
    
    const PORT = 8765;
    const ROOT = process.cwd();
    const RUNS = Number(process.argv[2] ?? 1);
    const DEADLINE = 12000;
    
    const WORKER_SRC = `
      import SQLiteESMFactory from '/dist/wa-sqlite.mjs';
      import * as SQLite from '/src/sqlite-api.js';
      import { OPFSCoopSyncVFS } from '/src/examples/OPFSCoopSyncVFS.js';
      import { SQLITE_OPEN_READWRITE, SQLITE_OPEN_CREATE } from '/src/sqlite-constants.js';
      const module = await SQLiteESMFactory({ locateFile: (f) => '/dist/' + f });
      const sqlite3 = SQLite.Factory(module);
      const vfs = await OPFSCoopSyncVFS.create('opfs', module);
      sqlite3.vfs_register(vfs, true);
      // The worker announces itself instead of the page posting straight away: this
      // worker uses top-level await, and a message posted before the module has
      // finished evaluating is dropped, not queued. The script in the issue posts
      // immediately, so its workers never receive their task and every run reports
      // HANG:0 whatever the VFS does.
      self.postMessage({ ready: true });
      self.onmessage = async (ev) => {
        const { id, filename } = ev.data;
        try {
          const db = await sqlite3.open_v2(filename, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE);
          // IF NOT EXISTS: without it the losers report "table t already exists",
          // which is settled but noisy.
          await sqlite3.exec(db, 'CREATE TABLE IF NOT EXISTS t (i INTEGER)');
          await sqlite3.exec(db, 'BEGIN');
          for (let i = 0; i < 200; i++) await sqlite3.exec(db, 'INSERT INTO t (i) VALUES (' + i + ')');
          await sqlite3.exec(db, 'COMMIT');
          self.postMessage({ id, status: 'ok' });
        } catch (e) {
          self.postMessage({ id, status: 'error', message: String((e && e.message) || e) });
        }
      };
    `;
    
    const PAGE = `<!DOCTYPE html>
    <html><body><script type="module">
    const params = new URLSearchParams(location.search);
    const filename = params.get('file');
    const n = Number(params.get('n'));
    const results = new Array(n).fill(null);
    const settle = (v) => { if (!document.body.dataset.result) document.body.dataset.result = v; };
    const deadline = setTimeout(() => {
      settle('HANG:' + results.map(r => r ?? '-').join(','));
    }, ${DEADLINE});
    Array.from({ length: n }, (_, id) => {
      const w = new Worker('/worker.mjs', { type: 'module' });
      w.onerror = (e) => settle('WORKER_ERROR:' + (e.message || e));
      w.onmessage = (ev) => {
        if (ev.data.ready) { w.postMessage({ id, filename }); return; }
        results[ev.data.id] = ev.data.status === 'ok' ? 'ok' : 'error(' + ev.data.message + ')';
        if (results.every(r => r !== null)) {
          clearTimeout(deadline);
          settle('DONE:' + results.join(','));
        }
      };
    });
    </script></body></html>`;
    
    const TYPES = { '.mjs': 'text/javascript', '.js': 'text/javascript', '.wasm': 'application/wasm' };
    const server = createServer(async (req, res) => {
      const url = new URL(req.url, 'http://127.0.0.1:' + PORT);
      // OPFS sync access handles need a worker; COOP/COEP matches the original report.
      res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
      res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp');
      const p = normalize(decodeURIComponent(url.pathname));
      if (p === '/') { res.setHeader('Content-Type', 'text/html'); res.end(PAGE); return; }
      if (p === '/worker.mjs') { res.setHeader('Content-Type', 'text/javascript'); res.end(WORKER_SRC); return; }
      if (p.startsWith('/dist/') || p.startsWith('/src/')) {
        try {
          const buf = await readFile(join(ROOT, p));
          res.setHeader('Content-Type', TYPES[extname(p)] ?? 'application/octet-stream');
          res.end(buf);
          return;
        } catch {}
      }
      res.statusCode = 404;
      res.end('not found');
    });
    await new Promise(r => server.listen(PORT, '127.0.0.1', r));
    
    async function attempt(context, filename, n) {
      const page = await context.newPage();
      try {
        await page.goto(`http://127.0.0.1:${PORT}/?file=${filename}&n=${n}`, { waitUntil: 'domcontentloaded' });
        await page.waitForFunction(() => document.body.dataset.result, undefined, { timeout: DEADLINE + 20000 });
        return await page.evaluate(() => document.body.dataset.result);
      } catch (e) {
        return 'DRIVER_TIMEOUT';
      } finally {
        await page.close();
      }
    }
    
    const browser = await chromium.launch();
    let hangs = 0;
    try {
      for (let run = 1; run <= RUNS; run++) {
        const context = await browser.newContext();
        const filename = `repro-${Date.now()}-${run}.db`;
        const result = await attempt(context, filename, 4);
        let poison = '';
        if (result.startsWith('HANG') || result === 'DRIVER_TIMEOUT') {
          hangs++;
          // Same context, same origin, same file, hung workers gone.
          poison = `  fresh connection afterwards: ${await attempt(context, filename, 1)}`;
        }
        await context.close();
        console.log(`run ${run}: ${result}${poison}`);
      }
    } finally {
      await browser.close();
      server.close();
    }
    console.log(`\n${hangs}/${RUNS} runs hung`);
    process.exit(hangs ? 1 : 0);

    Two deviations from the original script, both marked in the source: the workers
    announce themselves before being given work (above), and CREATE TABLE is
    IF NOT EXISTS, without which the losers report table t already exists —
    settled, but noise.

    Results

    Chromium 151.0.7922.34 (Playwright 1.62.1) on Linux, four module workers on
    one fresh OPFS file per run, git archive of each tree so that only
    src/examples/OPFSCoopSyncVFS.js differs:

    tree runs hung all four succeeded settled with database is locked
    master (07ad48c) 30 19 5 10
    master + #347 30 0 30 0

    With my own harness I also ran two more cells: Firefox 153 hangs as well (1 run
    in 10 on master, 0 in 10 with the patch), and a third tree carrying only the
    jUnlock commit of #347 — 0 hangs in 30, so that commit accounts for the whole
    fix and the #initialize commit in the PR is unrelated to this issue.

    A single connection on the same harness settles in ~110 ms, always.

    Beyond the hang: on master, only 5 of the 30 runs had all four
    connections succeed. In the others, connections got database is locked on a
    fresh file, where serialising would have been the correct outcome. With the
    patch every connection in every run succeeded, and no SQLITE_BUSY reached the
    application at all.

    The poisoned lock file did not reproduce

    After a hang the script closes the page — terminating the hung workers and
    releasing their access handles — and then runs the same full workload
    (open_v2 + CREATE TABLE + a 200-row transaction) with one fresh connection,
    on the same file, in the same browser context. It succeeded after every hang,
    19 for 19.

    So I can confirm the hang but not the persistent poisoning. One caveat: each run
    uses an ephemeral browser context, so a state that survives a browser restart in
    a persistent profile would not show up here. My guess is that what looked like a
    poisoned lock file was the deadlock itself seen from a new connection, with the
    hung workers still alive and still holding the handle — but it is a guess, and
    the persistent-profile case is untested.

    What deadlocks, from a vfs.log trace

    Endgame of a run where workers 2 and 3 hang (t in ms since worker start):

    55 w1 jLock / lock requested / returning SQLITE_BUSY / jUnlock
    56 w1 threw "database is locked"         <- the application gave up; w1 is idle
    56 w1 received notification              <- its channel handler fires once, then
                                                sets onmessage = null
    68 w1 lock acquired                      <- the request queued at t=55 wins the
    68 w1 creating access handles               Web Lock, for an idle connection
       (w1 never calls jUnlock again, and no longer listens)
    1064 .. 11063  w2, w3: notifying … notifying … notifying   (every 1000 ms, forever)
    

    Three things compound:

    1. jLock() sets isFileLocked = true before the SQLITE_BUSY return, and
      jUnlock() deliberately changes no state when isLockBusy — so a connection
      whose call ends on a BUSY keeps isFileLocked === true indefinitely.
    2. The handleRequestChannel.onmessage handler sets itself to null after one
      notification. With isFileLocked stale-true it only records
      isHandleRequested = true and defers the release to a jUnlock() that, for a
      connection whose statement has already failed, never comes — and it is now
      deaf to every later notification.
    3. The #requestAccessHandle() queued by that failed jLock() still runs to
      completion: it acquires the Web Lock and creates access handles for a
      connection that has nothing left to do
      . Everyone else waits on that Web Lock
      forever.

    Why #347 removes it

    The hand-over is what puts a connection on that path. Today the handle is
    released at the inner jUnlock(NONE) of a call that is not over; the relock
    inside the same call then returns SQLITE_BUSY, retry() has already spent its
    two attempts, and the application gets database is locked — which leaves
    exactly the idle connection with a queued handle request of step 3. Deferring
    the hand-over until the call has returned means the call completes: no spurious
    BUSY, and no orphaned handle request.

    That removes the trigger, not the underlying fragility. Points 1-3 are still
    true with the patch applied: any other route that leaves a connection idle after
    a SQLITE_BUSY can strand the access handle the same way, and a holder still
    listens for exactly one notification. A connection whose call ends on a BUSY
    arguably ought to clear isFileLocked, and the channel handler ought to stay
    installed for as long as the handle is held. I have not written that — it is a
    wider change than the one in #347, and I would rather you decide whether it
    belongs there.

  4. rhashimoto commented on Sep 26, 2026

    @rhashimoto
    Owner

    @lalexdotcom Wow, thanks for all the effort you put into this! AFAICT your analysis looks correct. Maybe the retry logic should be redesigned while keeping these scenarios and your last paragraph in mind.

  5. lalexdotcom commented on Sep 29, 2026

    @lalexdotcom
    Contributor

    I found a deterministic trigger on master (5be9cd14), and it is not in OPFSCoopSyncVFS but in retry() in src/sqlite-api.js.

    One worker, two databases, no contention. On the default (synchronous) build, a worker opens two fresh databases with OPFSCoopSyncVFS and runs the same small workload on both at once (Promise.all). That is the case you said in #104 should work in a non-Asyncify build. The second one fails with database is locked every time: 10 of 10 runs on Chromium 151 and on Firefox 153, and 20 of 20 in a longer battery. There is no other worker, so nothing holds the handle. With four workers doing the same on two shared databases, the connection that got the BUSY is left with its handle request in flight, the request takes the Web Lock for a connection that has given up, and the other workers wait forever: 17-20 runs of 20 hung, depending on the engine. That is exactly the stranded-handle state from my earlier comment, reached without any hand-over.

    Why. Module.retryOps is one list for the whole module, and retry() resets it to [] in its finally. With two calls in flight:

    1. The call on database A pushes its handle request and returns BUSY. The call on database B, starting next, finds A's request in the list and spends its first try waiting for it.
    2. A's request settles. B now calls f() for real, and jLock() pushes B's own request.
    3. A's finally runs Module.retryOps = [], which drops B's request from the list.
    4. B sees Module.retryOps.length === 0, so retry() returns SQLITE_BUSY to the application while B's request is still running.

    Two more consequences of the list being shared showed up when I fixed only the reset (removing just the operations the call had awaited):

    • A call still waits for other databases' requests. With four workers, one gets A's handle and waits for B's request, another gets B's and waits for A's: a deadlock with no BUSY at all, 7 runs of 20 on Chromium.
    • A rejected request fails every call waiting on the list. One injected createSyncAccessHandle failure made both databases of that worker fail, and the others hung.

    OPFSWriteAheadVFS is the only other VFS that pushes to retryOps, and the same two-database shape gives it a spurious database is locked too, 20 of 20 on both engines.

    What fixes it. Give each call its own list: a call waits only for the operations its own f() started, so it neither waits for, clears, nor fails on another call's. In the synchronous build those operations are started before f() returns. In the async builds they can be started after a suspension (JSPI suspends at every VFS call), so there the list has to be read once the call has settled. My first attempt read it at f()'s return, lost the operations under JSPI, and failed vfs_read_freshness on jspi.

       async function retry(f) {
         let rc;
    +    let ops = [];
         for (let retryCount = 0; retryCount < 2; ++retryCount) {
    -      // Wait for all pending retry operations to complete. This is
    -      // normally empty on the first loop iteration.
    -      if (Module.retryOps.length) {
    -        try { 
    -          await Promise.all(Module.retryOps);
    -        } finally {
    -          Module.retryOps = [];
    -        }
    +      // Wait only for the retry operations this call started.
    +      if (ops.length) {
    +        await Promise.all(ops);
    +      }
    +
    +      // Give the call its own list, so that it neither waits for, clears,
    +      // nor fails on another call's operations. A synchronous build starts
    +      // them before f() returns; an asynchronous one may start them after
    +      // a suspension, so there the list is read once the call has settled.
    +      const own = [];
    +      Module.retryOps = own;
    +      const result = f();
    +      ops = own.slice();
    +      rc = await result;
    +      if (result instanceof Promise) {
    +        ops = own.slice();
           }
    -      
    -      rc = await f();
    -      if (rc === SQLite.SQLITE_OK || Module.retryOps.length === 0) {
    +      if (rc === SQLite.SQLITE_OK || ops.length === 0) {

    With it, every shape above runs clean on the default build on both engines: 0 BUSY and 0 hangs, the injected failure fails only its own database, and the row counts match. The whole test suite passes (5830 tests). It removes the routes to a BUSY; the three points about the VFS in my earlier comment are unchanged.

    Would you like this as a PR, with a test for the two-database case that fails on master? Or would you rather fold it into the redesign you mentioned?

    Reproduction: repro-341-retryops.mjs. Run it from the root of a checkout, after npm i playwright: node repro-341-retryops.mjs [workers] [runs] [chromium|firefox]. On master with one worker, every run prints done ok + database is locked; with the change, done ok + ok.

  6. rhashimoto commented on Sep 29, 2026

    @rhashimoto
    Owner

    On the default (synchronous) build, a worker opens two fresh databases with OPFSCoopSyncVFS and runs the same small workload on both at once (Promise.all). That is the case you said in #104 should work in a non-Asyncify build.

    @lalexdotcom I did say that on the linked issue, but that was before any retry VFS existed. I also said:

    I haven't tried creating multiple database connections in a single WASM module instance, but I believe it should be possible as long there is at most one WASM call executing at a time. I probably wouldn't do this, though, because the bugs here will be race conditions which are difficult to track down.

    While it isn't the case that there are concurrent WASM calls here, I might argue that a retry is part of the same call.

    It's good to know this problem exists for multiple databases, but I don't see it as a high priority. I'm not aware of a lot of applications that want to use more than one database, and I suspect most of the ones that do can launch multiple Workers. I'm inclined to leave this alone.

    I think that the retry hack could use a good redesign and refactoring, but its usefulness could be declining. As of this month, JSPI is supported in all the major browsers. Maybe the next VFS generation won't need to bother with retry.

  7. lalexdotcom commented on Sep 29, 2026

    @lalexdotcom
    Contributor

    Fair enough — you did add the caveat on #104, and I agree that a call that awaits between retries is still in flight, so two databases with Promise.all is two calls in one module. Every trigger I found needs that shape, so it is outside the supported case.

    The diff and the repro stay in the comment above in case they are useful for the redesign.

  8. lalexdotcom commented on Sep 29, 2026

    @lalexdotcom
    Contributor

    One more thing, if you think it's worth it: a line in the docs of the VFS that use retryOps (OPFSCoopSyncVFS, OPFSWriteAheadVFS) saying that only one call may be in flight per module at a time, including across databases, and that a call stays in flight until its retries are done. That is the constraint these VFS actually need, and it isn't written anywhere a user would find it.

  9. rhashimoto commented on Sep 29, 2026

    @rhashimoto
    Owner

    One more thing, if you think it's worth it: a line in the docs of the VFS that use retryOps (OPFSCoopSyncVFS, OPFSWriteAheadVFS) saying that only one call may be in flight per module at a time, including across databases, and that a call stays in flight until its retries are done.

    That's a good idea. I added a sentence to the appropriate sections of the examples README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    response requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions