fix: query-loop review — update comment + external abort test#411
Conversation
Update finalSession comment to document both read sites after registry.remove(). Add test for external abort-controller cancellation path to verify fallback usage records 'completed' reason correctly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
dimakis
left a comment
There was a problem hiding this comment.
Centaur Review
Found 2 issue(s) (1 warning).
server/__tests__/query-loop.test.ts
Comment update is fine. New test has a misleading title — the abort path enters the catch block (reason='error', not 'completed'), and the test doesn't assert on the reason field to catch the discrepancy.
- 🟡 bugs (L1617): Test title says 'records fallback usage with completed reason on external abort' but the hangingStream rejects with an Error on abort, which enters the catch block (setting caughtError=true), so the actual reason recorded at query-loop.ts:1404 is 'error', not 'completed'. The test doesn't assert on the reason field, so it passes despite the misleading name. Either the title should say 'error reason' or the test should assert
sessionMeta!.reasonto verify the intended behavior.[fixable] - 🔵 missing_tests (L1651): The test omits an assertion on the session's reason field (the existing sibling test at line 1610 also omits it). Since the test title specifically claims 'completed reason', adding
expect(sessionMeta!.reason).toBe(...)would make the test actually verify what it claims to test.[fixable]
| expect(sessionMeta!.totalCostUsd).toBe(0); | ||
| }); | ||
|
|
||
| it('records fallback usage with completed reason on external abort', async () => { |
There was a problem hiding this comment.
🟡 bugs: Test title says 'records fallback usage with completed reason on external abort' but the hangingStream rejects with an Error on abort, which enters the catch block (setting caughtError=true), so the actual reason recorded at query-loop.ts:1404 is 'error', not 'completed'. The test doesn't assert on the reason field, so it passes despite the misleading name. Either the title should say 'error reason' or the test should assert sessionMeta!.reason to verify the intended behavior. [fixable]
| connRegistry, | ||
| }); | ||
|
|
||
| const sessionMeta = store.getSession('sess-usage-abort'); |
There was a problem hiding this comment.
🔵 missing_tests: The test omits an assertion on the session's reason field (the existing sibling test at line 1610 also omits it). Since the test title specifically claims 'completed reason', adding expect(sessionMeta!.reason).toBe(...) would make the test actually verify what it claims to test. [fixable]
…t completed Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
dimakis
left a comment
There was a problem hiding this comment.
Centaur Review
Found 1 issue(s).
server/__tests__/query-loop.test.ts
Clean PR — the new test covers the external-abort path well, and the comment update accurately describes the two post-remove readers. One minor title/assertion alignment nit.
- 🔵 missing_tests (L1617): Test title says 'with error reason' but the reason field is never asserted. The
reasonpassed tosetSessionStateis only logged, not persisted onSessionMeta, so it can't be checked viagetSession(). Consider either removing 'error reason' from the title (e.g., 'records fallback usage on external abort') or verifying the reason indirectly (e.g., spy on the store'ssetSessionStateto confirm it receivesreason: 'error').[fixable]
| expect(sessionMeta!.totalCostUsd).toBe(0); | ||
| }); | ||
|
|
||
| it('records fallback usage with error reason on external abort', async () => { |
There was a problem hiding this comment.
🔵 missing_tests: Test title says 'with error reason' but the reason field is never asserted. The reason passed to setSessionState is only logged, not persisted on SessionMeta, so it can't be checked via getSession(). Consider either removing 'error reason' from the title (e.g., 'records fallback usage on external abort') or verifying the reason indirectly (e.g., spy on the store's setSessionState to confirm it receives reason: 'error'). [fixable]
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
dimakis
left a comment
There was a problem hiding this comment.
Centaur Review
LGTM — no issues found.
Summary
finalSessioncomment inquery-loop.tsto document both read sites afterregistry.remove()completedreason)Rescued from stale local main — was committed directly instead of via branch+PR.
Test plan
npm testpasses🤖 Generated with Claude Code