Skip to content

add failing bug-report test: a rejected bulkWrite permanently wedges the incremental-write queue - #9026

Open
kilbot wants to merge 1 commit into
pubkey:masterfrom
kilbot:bug-report-incremental-write-wedge
Open

add failing bug-report test: a rejected bulkWrite permanently wedges the incremental-write queue#9026
kilbot wants to merge 1 commit into
pubkey:masterfrom
kilbot:bug-report-incremental-write-wedge

Conversation

@kilbot

@kilbot kilbot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Failing bug-report test, per the template instructions.

The bug: one rejected storage bulkWrite permanently wedges IncrementalWriteQueue.

triggerRun() sets isRunning = true but only resets it at the end of the happy path — there is no try/finally. If storageInstance.bulkWrite() rejects (a transient io error), triggerRun() exits with isRunning still true. The items of that run are never rejected, and every later addWrite() parks behind the isRunning early-return. After a single transient storage failure, every incrementalModify() / incrementalPatch() on that collection hangs forever, and the only trace is an unhandledRejection.

The test: insert a doc, make the next bulkWrite with context 'incremental-write' reject once, call incrementalPatch() twice. Expected: the first call rejects with the storage error, the second succeeds. Actual: neither promise ever settles.

AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
+ 'still pending after 2 seconds'
- 'settled'

I also verified the test passes when triggerRun()'s body is wrapped in try/finally (reset isRunning, reject the taken-over items — mirroring the existing preWrite failure handling), so the test detects the fix.

pull Bot pushed a commit to HumpfTech/monorepo that referenced this pull request Sep 1, 2026
…writes

Upstream rxdb bug (our failing-test PR: pubkey/rxdb#9026):
IncrementalWriteQueue.triggerRun() has no try/finally, so one rejected
storage bulkWrite leaves isRunning=true forever - the failing caller and
every later incrementalModify() on that collection hang, never settling,
with only an unhandledRejection as a trace. Our sync scheduler persists
task state through incrementalModify, so a single transient storage
failure could silently freeze it (candidate mechanism for wedge shape b,
proven in isolation, not yet confirmed in CI).

pnpm patch on rxdb@17.4.0 (both esm and cjs builds): wrap triggerRun's
body in try/catch/finally - reject the taken-over items so callers
observe the error, always reset isRunning. Identical fix verified green
against upstream's own bug-report test harness before applying here.

Pin test (packages/database/src/rxdb-incremental-write-patch.test.ts)
goes through the public API and was verified red-first on unpatched
rxdb (caller never settles, jest timeout) then green on the patch;
it also proves the queue recovers for the write after the failure.

Tested: pin test 1/1; packages/database jest 456/456; sync-engine
vitest 1688/1690 (2 skipped) with --maxWorkers=2; lint 0; typecheck 0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant