test: full local npm test fails timer-sensitive messenger-bridge, mcp staleModel and gui router tests on macOS (CI green) #296
Copy link
Copy link
Closed
Description
Problem
npm test on a macOS developer machine (Node v22.22.0, darwin 27.0.0) fails the same tests on a clean origin/dev (fff148f) checkout as on feature branches, while hosted CI passes:
plugins/codexclaw/components/messenger-bridge/test/media-handler.test.ts: "download timeout aborts a stalled operation", "download timeout returns even when an operation ignores AbortSignal", "writeAll retries partial file writes until every byte is persisted", "media download gate rejects overload without building an unbounded wait queue"plugins/codexclaw/components/messenger-bridge/test/rate-limit.test.ts: threerateLimitSleeptestsplugins/codexclaw/components/subagent-config/test/mcp.test.ts: "timeout yields staleModel null with staleReason"plugins/codexclaw/gui/test/router.test.ts(file-level failure)
The messenger-bridge ones report failureType: 'cancelledByParent' / "Promise resolution is still pending but the event loop has already resolved". They pass when run alone (node plugins/codexclaw/scripts/test.mjs <those two files> → 17/17), so they look like timer/event-loop interactions under the full single-process run (--test-concurrency=1).
Evidence
- origin/dev full run: 3771 tests, 3757 pass, same failure set.
- Feature branch full run (PR feat(state): resolve durable codexclaw state outside enterprise checkouts #295): 3790 tests, 3776 pass, same failure set; hosted ubuntu/macos/windows CI green.
Impact
Local "full suite green" is never observable, so every PR body has to explain the same baseline failures.
Found while working on #295 (external state root, thread mcp:d1b4ca86-768b-491a-81d8-bd51b0a09c96).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
lidge-jun commentedon Oct 27, 2026
Fixed in #325 (merged into dev). The cause is the Node version: tests do not interfere with each other in a single process. On Node 22.22.0, the media-handler, rate-limit and mcp
staleModeltests await promises kept alive only byunref()'d timers (stream-download.ts,rate-limit.ts,mcp.ts). Node 22's runner sees an empty event loop and cancels the test and the rest of its file, which explains the collateralwriteAll/gate cancellations. Node 24/26 keep waiting, which is why hosted CI was green. Those six tests now hold one referenced interval for their own lifetime and carry a 10 s timeout. Productionunref()is unchanged. On Node 22.22.0 the three files went from 34 tests / 8 cancelled to 34 passed, and the full suite ran 3879 tests with 0 fail, 0 cancelled. The gui router file-level failure did not reproduce on current dev. The other local-only failure found on macOS is the worktree-guard path budget (see #297), also fixed.