bug: flaky ZCode pending boundary timeout assertion
Describe the bug
ZCode's pending preserves concurrent receipts and pauses unknown writes test intermittently returns failed instead of unknown.
Its 800 ms timeout includes filesystem work before HTTP dispatch. If that work exhausts the budget, the request is never sent and failed is valid. A controlled delay reproduces this path; the original CI log does not establish whether it was the cause there.
Steps to reproduce
-
Check out
42069c5e05fa0f4739394c7d3bc613c909524172(PR #2052). -
Run:
node --test integrations/zcode/plugins/powercontext/tests/*.test.mjs -
The failure is intermittent. To reproduce the pre-dispatch path, inject a 900 ms delay before the final temporary pause-file unlink in the test's
unknowncase. This produces the same assertion failure without dispatching the intended request.
Expected behavior
Synchronize cancellation with fixture request arrival so the test exercises uncertain delivery reliably. Preserve failed for unsent requests and unknown for uncertain delivery.
Actual behavior
- Initial CI failure: 22 passed, 1 failed;
boundary.test.mjs:285expectedunknown, receivedfailed. - Same-commit rerun: all 23 Node tests and the complete acceptance job passed without code changes.
Environment
- CI:
windows-latest, Node 24.21.0; ZCode acceptance /controlled-cli. - Controlled reproduction: Linux, Node 22.22.1. The injected delay is not a measurement of Windows runner latency.
Are you willing to submit a PR to fix this bug?
- [ ] Yes, I would like to submit a PR.
I'd like to take this one.
Plan: in the unknown case, hold the fixture response and abort the flush from the server's request-arrival hook instead of relying on the 800 ms timeout, so cancellation always happens after dispatch and the test reliably exercises uncertain delivery.