oficina / slides Public

Hold the event loop open while a save's timeout fires

AbortSignal.timeout's timer is unref'd. Node 24's test runner keeps the
loop alive anyway, but Node 22's does not, so on hosted CI the file would
end at this await and cancel the twelve tests after it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 141e5d26a66083ddf7a8bdb62c4e86baf26cc07d parent ddf880b
1 file changed, +8 −1
  • fixtures/save-queue.test.mjs +8 −1
diff --git a/fixtures/save-queue.test.mjs b/fixtures/save-queue.test.mjs
index 243f135..5652d65 100644
--- a/fixtures/save-queue.test.mjs
+++ b/fixtures/save-queue.test.mjs
@@ -323,7 +323,14 @@ test('a save is sent keepalive, and given up if it is never answered', async ()
assert.equal(answerTimeoutMs(new Uint8Array(8)), SAVE_TIMEOUT_MS + 1 + 5000)
const { signal } = await saveRequest(new Uint8Array(1), { timeoutMs: 10 })
assert.ok(signal, 'a save on the wire forever would stop every save after it')
- await new Promise((resolve) => signal.addEventListener('abort', resolve))
+ // AbortSignal.timeout's timer does not hold the event loop open. Node
+ // 24's test runner keeps it open anyway; Node 22's does not, so with
+ // nothing else pending it ends the file here and cancels every later
+ // test. A held timer keeps the loop alive until the signal fires.
+ await new Promise((resolve) => {
+ const hold = setTimeout(() => {}, 60_000)
+ signal.addEventListener('abort', () => { clearTimeout(hold); resolve() })
+ })
assert.equal(signal.reason.name, 'TimeoutError')
})