Skip to content

Commit 3f024dc

Browse files
kriszypclaude
andcommitted
Clear the race timeout on the successful path (codex nit)
Promise.race() doesn't cancel the losing branch, so the 10s timeout added in the previous commit stayed referenced even after secondCommitStarted won, keeping a targeted run of this file alone alive for ~10s past the actual result. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent e3cf4c9 commit 3f024dc

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

unitTests/resources/outstandingCommitTracking.test.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,23 @@ describe('Outstanding commit tracking', () => {
135135
// forever with `Transaction.prototype.commit` left monkeypatched, breaking every later test
136136
// that touches RocksDB. This timeout is comfortably inside the 15s test timeout, so `finally`
137137
// 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-
]);
138+
let timeoutHandle;
139+
try {
140+
await Promise.race([
141+
secondCommitStarted,
142+
new Promise(
143+
(_resolve, reject) =>
144+
(timeoutHandle = setTimeout(
145+
() => reject(new Error("TrackB's commit was never invoked (tracking regression?)")),
146+
10000
147+
))
148+
),
149+
]);
150+
} finally {
151+
// Otherwise the successful path leaves this timer referenced, keeping a targeted run of
152+
// this file alone alive for ~10s after the result is already known.
153+
clearTimeout(timeoutHandle);
154+
}
144155
// TrackA's node is unlinked before `this.next.commit()` runs (see the comment above), so by
145156
// this point count===1 can only be TrackB's held commit — no polling/racing required.
146157
const outstanding = getOutstandingCommits();

0 commit comments

Comments
 (0)