From 7ed17d228d5849b16cd22d6c14eb05f5477a38d5 Mon Sep 17 00:00:00 2001 From: Ryan Gapac Date: Mon, 28 Sep 2026 08:19:53 +0800 Subject: [PATCH 1/2] test: keep the event loop alive while a host handler is pending The fake host's per-handler timeout timer was unref'd, so an awaited emit whose handler promise stayed pending had no referenced wakeup and the event loop drained before the timeout could advance the dispatch. node:test then cancelled the remaining tests with 'Promise resolution is still pending but the event loop has already resolved'. Every emit clears the timer before it returns, so referencing it for the dispatch never outlives the emit. --- tests/host-compat.test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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; } From 0d3a80743d404e8400f9977a9239ee3fe5ad868b Mon Sep 17 00:00:00 2001 From: Ryan Gapac Date: Mon, 28 Sep 2026 08:23:30 +0800 Subject: [PATCH 2/2] chore: version bump to 0.73.1 --- CHANGELOG.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) 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",