diff --git a/CHANGELOG.md b/CHANGELOG.md index e0f8c912..48138557 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ How to keep this current: add the entry in the same pull request as the change, +## 0.73.1 + +### Tests + +- `tests/host-compat.test.ts`: the fake host's per-handler timeout stays referenced while a dispatch runs and is cleared before `emit()` returns, so an awaited `emit()` always has a loop wakeup. The timer was unref'd, so on Node 22 the event loop could drain mid-dispatch and node:test cancelled the rest of the file with `Promise resolution is still pending but the event loop has already resolved`. + ## 0.73.0 ### Fixed diff --git a/package.json b/package.json index 97d1d157..8dd90322 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pi-warden", - "version": "0.73.0", + "version": "0.73.1", "description": "Makes the Pi agent follow your project's rules. Jev judges every write against your pi-warden.md and quotes the broken rule back to the agent, names slop, breaks stuck loops, calls out unverified done claims, compresses large tool output, and holds the rare destructive command. Built on pi-typesafe.", "type": "module", "license": "MIT", diff --git a/tests/host-compat.test.ts b/tests/host-compat.test.ts index b762bec7..72b679a6 100644 --- a/tests/host-compat.test.ts +++ b/tests/host-compat.test.ts @@ -19,11 +19,13 @@ function fakeHost(extras: Record = {}) { let result: unknown; let error: unknown; // omp's per-handler timeout: the host stops awaiting a handler that runs too long and - // advances to the next one; the handler's promise keeps running. + // advances to the next one; the handler's promise keeps running. The timer stays + // referenced for the dispatch: an unref'd timeout is not a loop wakeup, so an awaited + // emit whose handler promise stays pending would drain the loop before the timeout can + // advance to the next handler. Every emit clears the timer before it returns. let onTimeout = (): void => {}; const timeout = new Promise(resolve => { onTimeout = resolve; }); const timer = setTimeout(onTimeout, handlerTimeoutMs ?? 2 ** 30); - timer.unref?.(); const run = (handler: Handler) => Promise.race([Promise.resolve(handler(payload, ctx)), timeout]); for (const handler of handlers.get(event) ?? []) { try { result = await run(handler); } catch (failure) { error ??= failure; }