-
-
Notifications
You must be signed in to change notification settings - Fork 52.7k
Description
Summary
src/agents/subagent-announce.format.test.ts — test "waits for updated synthesized output before announcing nested subagent completion" fails intermittently on Windows CI (shard 1/2 or 2/2).
Root Cause
FAST_TEST_MODE is evaluated at module load time (line 46 of subagent-announce.ts):
const FAST_TEST_MODE = process.env.OPENCLAW_TEST_FAST === "1";But the test sets vi.stubEnv("OPENCLAW_TEST_FAST", "1") in beforeEach (line 161), which runs after beforeAll where the module is imported (line 148). If OPENCLAW_TEST_FAST is not already set in the environment when the module loads, FAST_TEST_MODE is false for the entire test run.
With FAST_TEST_MODE = false:
RETRY_INTERVAL_MS= 100ms (not 8ms)minReplyChangeWaitMs= 250ms (not 20ms)- The test passes
timeoutMs: 100, somaxWaitMs = max(250, min(100, 2000)) = 250ms
The poll loop has ~250ms budget with 100ms sleeps. On Windows, setTimeout(100) routinely overshoots to 115–150ms due to the default timer resolution (~15.6ms). This gives only 1–2 iterations — not enough to reach the 3rd chatHistory mock call that returns "Final synthesized answer.".
On Linux CI, OPENCLAW_TEST_FAST=1 is typically set in the environment already, so the module-level const captures true and the test passes.
Evidence
- Seen on multiple merged PRs: fix(cron): avoid marking queued announce paths as delivered #29716, Feishu: fix locale-wrapper post parser test #29576, fix(feishu): honor wildcard group config for reply policy #29456, feat(gateway): enable Android notify + notification events #29440, fix(azureopenai): update correct request body format for azure openai endpoints #29421, fix(cli): allow Ollama apiKey config set without predeclared provider #29299, fix(gateway): allow required Google Fonts origins in Control UI CSP #29279
- Always Windows-only, always
checks-windows (node, test, shard N/2) - Always this same test or similar timing-dependent tests in the same file
Suggested Fix
Set OPENCLAW_TEST_FAST=1 in the environment before importing the module, so the module-level const picks it up. For example, move the env stub into beforeAll before the dynamic import:
beforeAll(async () => {
process.env.OPENCLAW_TEST_FAST = "1";
({ runSubagentAnnounceFlow } = await import("./subagent-announce.js"));
// ...
});