Skip to content

Keep the Node 22 plugin tests alive while they await unref'd timers - #3437

Merged
Birfy merged 1 commit into
mainfrom
dev/3436-node22-plugin-test-keepalive
Nov 29, 2026
Merged

Birfy merged 1 commit into
mainfrom
dev/3436-node22-plugin-test-keepalive

Conversation

@Birfy

@Birfy Birfy commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

Node 22 can end a whole-directory run of runtime/flybot-workspace-web with
cancelled > 0 and exit code 1 while no assertion failed, because two timers the
tests await are unref'd: the runtime() rejection timer (src/host.js:28) and
the memory capture scan scheduler (features/memory/capture.js:198). Both are
correct in production — a server always has a listening socket — so the tests are
what has to change.

This slice keeps the test's event loop alive while it awaits, and changes nothing
else.

Related #3436. Refs #3434.

Change

  • test/features.test.js: the runtime() timeout test wraps its assert.rejects
    in a 1 s keep-alive timer, cleared in finally.
  • test/memory-extras.test.js: the group-capture test wraps its
    Promise.race([extracting, delay(6000, null, {ref: false})]) in a 6 s
    keep-alive timer, cleared in finally.
  • src/host.js and features/memory/capture.js are untouched. Removing the
    unref calls would instead change production behaviour: the runtime() timer
    would hold the event loop open for up to the default timeoutMs = 15_000.

Evidence (local, not CI)

Measured on the content of main at
1a981717f2b708f796b820ec871058ab339b8fa2 (tree b43a727d), rebuilt from
codeload and verified byte-identical (git add -Af then write-tree =
b43a727d). A/B on two copies that differ only in these two files, same shell,
same TMPDIR, Node v22.23.5, --test-concurrency=2.

This branch is cut from main at e6aeae4e (tree 93a2fb2d), after #3435.
#3435 edited test/features.test.js only inside three other tests (it threads
TEST_ENV there); the two tests this slice changes - the runtime() timeout
test and the group-capture race - are unchanged, and test/memory-extras.test.js
is untouched by #3435.

command main content with this change
node --test --test-name-pattern='runtime\(\) resolves' test/features.test.js 1 test / 1 cancelled, exit 1 1 / 1 pass, exit 0
node --test test/features.test.js 6 / 4 pass / 2 cancelled, exit 1 6 / 6 pass, exit 0
node --test test/memory-extras.test.js 11 / 9 pass / 2 cancelled, exit 1 11 / 11 pass, exit 0
node --test --test-concurrency=2 test/*.test.js 497 / 470 pass / 17 fail / 10 cancelled, exit 1 497 / 474 pass / 17 fail / 6 cancelled, exit 1

The whole-directory line is the strict A/B: exactly four results move from
cancelled to pass (#176 #177 #233 #234), the fail count does not change, and
exactly four results move. QA Engineer reproduced the same four-result delta on a
second host (their absolute counts differ: 482 / 11 / 4 to 486 / 11 / 0),
which is expected — see below.

Absolute whole-directory counts on this content are host-dependent, because the
suite still inherits host environment variables (Refs #3434); that is why the
table compares per-file counts and the delta rather than claiming a green
directory.

Node v24.22.3, same two copies: 497 / 486 pass / 11 fail / 0 cancelled in
both, so the keep-alives are a no-op on the version CI uses. The 11 failures are
the host-environment family from #3434, identical before and after.

Non-goals

  • No Node 22 job is added to CI, and no current CI conclusion is affected: the
    only job that runs this directory is flybot-runtime-image.yml on Node 24.
  • Does not touch the second cancellation cluster in test/social-templates.test.js
    (#442-#447), whose cause is a feature that fails to load, not an unref'd
    timer.
  • Does not claim the directory is green, and does not change any assertion.

@Birfy

Birfy commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator Author

Lead review — slice, evidence, scope

Head fd392ab5b756b597d1110fb03567c93d3524cb7a (refs/pull/3437/head), base main
e6aeae4e2bae52d13e721506a41e598a222655ea, one commit Keep the Node 22 plugin tests alive while they await unref'd timers, 2 files +15/-2, tree dffcaed5782aedb4f710695d9d06af9bd5d2e93e.

Slice

Two test-side keep-alive timers, one per cancelled site:

  • test/features.test.js: the runtime() timeout test keeps the loop alive around
    assert.rejects(...).
  • test/memory-extras.test.js: the group-capture test keeps the loop alive around its
    Promise.race.

Both are finally-cleared. No assertion, no timeout value, and no production file changes.
src/host.js:28 and features/memory/capture.js:198 stay as they are: removing their unref
would change production behaviour, because the runtime() timer would then hold the loop for up
to the default timeoutMs = 15_000. That is why the fix is on the test side.

Local evidence (measured by me, not CI)

Node v22.23.5, --test-concurrency=2, two clean trees from codeload (base e6aeae4e, head
fd392ab5); diff -rq between them reports exactly these two files.

run base e6aeae4e head fd392ab5
--test-name-pattern='runtime\(\) resolves' test/features.test.js 1 test / 0 pass / 1 cancelled / exit 1 1 / 1 pass / 0 cancelled / exit 0
test/features.test.js 6 / 4 pass / 2 cancelled / exit 1 6 / 6 / 0 / exit 0
test/memory-extras.test.js 11 / 9 pass / 2 cancelled / exit 1 11 / 11 / 0 / exit 0
test/*.test.js (whole directory) 497 / 493 pass / 0 fail / 4 cancelled / exit 1 497 / 497 / 0 / 0 / exit 0

Whole-directory absolute counts are host-dependent: the suite still inherits host environment
(Refs #3434). On this host the base fail count is 0; on the author's host both columns carry 17
fails and the same four-result delta. The delta is the evidence; the absolute numbers are not.

Independent runs on the same content

  • Runtime Dev (author): same four-result delta - 1 cancelled -> 1 pass, 9 pass / 2 cancelled -> 11/11, whole directory 470 -> 474 pass with the fail count unchanged.
  • QA Engineer reproduced the same per-file deltas on the two blobs before this branch existed, and
    reconstructed this head from them with git hash-object.
  • QA's re-run against this exact head is outstanding. The local table above is my own run; it is
    the only exact-head local evidence in this record.

CI (this head only)

check-runs for fd392ab5: total 18 == returned 18, 18/18 completed + success, no
in_progress, failure, cancelled or neutral, and all 18 head_sha equal this head.

One reading note: the only job that runs this directory is flybot-runtime-image.yml ->
Image recipe contract tests on Node 24, where both keep-alives are a no-op. Its green says "no
Node 24 regression", not "the Node 22 fix works". The fix evidence is the Node 22 table.

Out of scope / residuals

  • The second cancellation cluster in test/social-templates.test.js (#442-#447,
    cancelledByParent from a feature that fails to load) has a different cause and stays in the
    issue.
  • No Node 22 CI job is added; Node 22 coverage remains a local practice.
  • This is not a parity claim and not an acceptance sign-off. It records one slice on one head.

Related #3436. Refs #3434.

@Birfy
Birfy added this pull request to the merge queue Nov 29, 2026
Merged via the queue into main with commit ee8ae6d Nov 29, 2026
18 checks passed
@Birfy
Birfy deleted the dev/3436-node22-plugin-test-keepalive branch November 29, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:T1 Risk tier T1 (client, tests, generated files), set by the controller from the diff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant