Skip to content

test: keep the fake host timeout referenced during dispatch - #133

Merged
DevMortimer merged 2 commits into
mainfrom
host-compat-flake
Sep 28, 2026
Merged

DevMortimer merged 2 commits into
mainfrom
host-compat-flake

Conversation

@DevMortimer

Copy link
Copy Markdown
Owner

tests/host-compat.test.ts fakes the host's per-handler timeout with a timer it unref'd, so an awaited emit() whose handler promise stayed pending had no referenced wakeup: on Node 22.19.0 the event loop could drain mid-dispatch and node:test cancelled the rest of the file with

failureType: 'cancelledByParent'
error: 'Promise resolution is still pending but the event loop has already resolved'

which is what cancelled adaptHost: host timeout advances to settle even if an agent_end promise remains pending and adaptHost: command contexts get getSystemPromptOptions with the active skills.

That is the intermittent Check (Node 22.19.0) failure: the same tree failed the main push run and the v0.73.0 tag run, and passed the pull request run and both reruns.

The timer now stays referenced for the dispatch and is cleared before emit() returns, so it never outlives a dispatch. Tests only — no production code changes.

Verified:

  • pre-fix test file on Node 22.19.0: 8 of 8 runs fail with the error above
  • fixed test file on Node 22.19.0: 10 of 10 runs green
  • npm run check: exit 0, 1186 tests, 0 failed

The 0.73.1 version bump is the last commit, as required by the release process.

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.
@DevMortimer
DevMortimer merged commit 5fb96fd into main Sep 28, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant