Skip to content

Commit e3cf4c9

Browse files
kriszypclaude
andcommitted
Bound the chained-commit test's wait so a regression can't hang the suite
Per codex's independent pre-push review: an unbounded await on secondCommitStarted would hang forever if a regression ever prevented TrackB's commit from being invoked (or done rejected before reaching it). Mocha's own test timeout does not cancel a still-running async test function, so the try/finally's cleanup — restoring the monkeypatched Transaction.prototype.commit and releasing the held promise — would never run, breaking every later RocksDB-touching test in the process. Race the signal against a bounded timeout so the finally block always gets a chance to run. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 3e77025 commit e3cf4c9

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

unitTests/resources/outstandingCommitTracking.test.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,18 @@ describe('Outstanding commit tracking', () => {
129129
await TrackB.put(4, { name: 'chain-b-2' }, context);
130130
chained = !!context.transaction?.next;
131131
});
132-
await secondCommitStarted;
132+
// Race against a bounded timeout, not a bare await: if a regression means TrackB's commit is
133+
// never invoked, `secondCommitStarted` would otherwise never settle. Mocha's own test timeout
134+
// doesn't cancel this still-running async function, so an unbounded await here would hang
135+
// forever with `Transaction.prototype.commit` left monkeypatched, breaking every later test
136+
// that touches RocksDB. This timeout is comfortably inside the 15s test timeout, so `finally`
137+
// below still gets to run and restore everything before mocha's own timeout would fire.
138+
await Promise.race([
139+
secondCommitStarted,
140+
new Promise((_resolve, reject) =>
141+
setTimeout(() => reject(new Error("TrackB's commit was never invoked (tracking regression?)")), 10000)
142+
),
143+
]);
133144
// TrackA's node is unlinked before `this.next.commit()` runs (see the comment above), so by
134145
// this point count===1 can only be TrackB's held commit — no polling/racing required.
135146
const outstanding = getOutstandingCommits();

0 commit comments

Comments
 (0)