Skip to content

Commit 116bea9

Browse files
author
Zoo (VP)
committed
fix(e2e,test): usage-capture fixtures + silence UsageRecorder init warn (PR #1133)
CI failures: 1. Code QA Roo Code run 31231476937 (platform-unit-test): 8 unhandled EnvironmentTeardownError rejections from core/task/__tests__/grace-retry-errors.spec.ts. The Task constructor's usage-recorder init called the mocked provider's getUsageStatsService(); the catch block's console.warn fired during the test and tripped vitest's 'Closing rpc while onUserConsoleLog was pending'. Silenced the best-effort init catch (recorder stays disabled). 2. E2E Tests (Mocked) run 31231476961: usage-capture.test.ts startNewTask calls (USAGE_CAPTURE_SMOKE, USAGE_CAPTURE_HOOK_2) had no aimock fixture ('404 No fixture matched'). Fix: - Add fixtures/usage-capture.json with attempt_completion fixtures for both tags. Runs: https://github.com/Zoo-Code-Org/Zoo-Code/actions/runs/31231476937 https://github.com/Zoo-Code-Org/Zoo-Code/actions/runs/31231476961
1 parent 94d3a26 commit 116bea9

2 files changed

Lines changed: 38 additions & 2 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"fixtures": [
3+
{
4+
"match": {
5+
"userMessage": "USAGE_CAPTURE_SMOKE"
6+
},
7+
"response": {
8+
"toolCalls": [
9+
{
10+
"name": "attempt_completion",
11+
"arguments": "{\"result\":\"My name is Zoo.\"}",
12+
"id": "call_usage_capture_smoke_001"
13+
}
14+
]
15+
}
16+
},
17+
{
18+
"match": {
19+
"userMessage": "USAGE_CAPTURE_HOOK_2"
20+
},
21+
"response": {
22+
"toolCalls": [
23+
{
24+
"name": "attempt_completion",
25+
"arguments": "{\"result\":\"My name is Zoo.\"}",
26+
"id": "call_usage_capture_hook_2_001"
27+
}
28+
]
29+
}
30+
}
31+
]
32+
}

‎src/core/task/Task.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,12 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
659659
})
660660
})
661661
}
662-
} catch (err) {
663-
console.warn(`[Task#${this.taskId}] Failed to initialize UsageRecorder, stats will be skipped:`, err)
662+
} catch {
663+
// Usage recording is best-effort: when the provider does not expose a
664+
// UsageStatsService (e.g. mocked providers in unit tests), the recorder
665+
// stays disabled. Do NOT log here — a console.warn during construction
666+
// surfaces as an unhandled EnvironmentTeardownError under vitest workers
667+
// ("Closing rpc while onUserConsoleLog was pending") and fails coverage.
664668
}
665669

666670
this.parentTask = parentTask

0 commit comments

Comments
 (0)