powermem icon indicating copy to clipboard operation
powermem copied to clipboard

bug: flaky ZCode pending boundary timeout assertion

Open PsiACE opened this issue 1 month ago • 1 comments

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

  1. Check out 42069c5e05fa0f4739394c7d3bc613c909524172 (PR #2052).

  2. Run:

    node --test integrations/zcode/plugins/powercontext/tests/*.test.mjs
    
  3. 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 unknown case. 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:285 expected unknown, received failed.
  • 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.

PsiACE avatar Oct 19 '26 13:10 PsiACE

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.

luochen211 avatar Oct 20 '26 02:10 luochen211