fix: resolve abort listener leak, VAD sparse arrays, and lint issues#41
fix: resolve abort listener leak, VAD sparse arrays, and lint issues#41rsagacom wants to merge 1 commit into
Conversation
- agent-loop.ts / code-mode/service.ts: remove spurious removeEventListener calls from timer success callbacks; the once-true listener should only be removed in the abort handler, otherwise shared AbortSignals lose listeners prematurely - vad: replace new Array(n) with Array.from to eliminate sparse arrays and resolve unicorn/no-new-array lint warnings - stepfun-stateless.ts: drop unused catch parameter 'e' Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Thanks for the contribution! To get this ready to merge:
Full conventions: |
|
Hi @Misaka477, thanks for the fixes. I noticed #68 appears to be a near-duplicate of this PR — both cover the same abort listener leak in agent-loop.ts/code-mode/service.ts, the VAD sparse array fix in cli-handlers.ts/resolver.ts, and the unused catch parameter in stepfun-stateless.ts. Could you confirm if #68 should be closed in favor of this one, or if there are meaningful differences I'm missing? |
|
Hi @rsagacom, thanks for this PR. The repo's CONTRIBUTING.md requires every PR to reference an issue (CI link-check enforces this). This PR currently doesn't close or reference any issue. Given the overlap with #68, I'd suggest either: (a) close this PR in favor of #68 and let that one carry the fix, or (b) rebase onto #68 and add a Closes reference to #80 if you believe this version has meaningful differences. |
|
Summary
Fixes three categories of issues found during code review:
Bug Fixes
1. Abort listener leak in sleep/delay (
agent-loop.ts,code-mode/service.ts)The
sleep()anddelay()helper functions were callingsignal.removeEventListener('abort', abort)in the timer success callback. This prematurely removes the abort listener from shared AbortSignals, causing other operations waiting on the same signal to miss abort notifications.Root cause: When a timer completes normally, it should not clean up the abort listener — the
{ once: true }option ensures the listener auto-removes after firing. Removing it on success breaks signal sharing patterns (e.g. combined abort signals in session management).2. VAD edit distance sparse array initialization (
vad/resolver.ts,vad/cli-handlers.ts)new Array(n)creates sparse arrays with empty slots (notundefinedvalues). While the DP loop fills all elements before access, this triggersunicorn/no-new-arraylint warnings and is semantically incorrect for the edit distance algorithm.Fix: Changed to
Array.from({ length: n }, (_, j) => j)which correctly initializes all elements.Code Quality
3. Unused catch parameter (
stepfun-stateless.ts)Removed unused
eparameter from catch block inonMessage().4. Prettier formatting (
docs/skills/pr-review-decision.md)Fixed formatting inconsistencies that were causing
pnpm checkto fail.Manual Test Plan
pnpm check— all checks pass (1152 tests, 0 lint errors, format clean)pnpm test -- packages/realtime/src/vad/resolver.test.ts— edit distance still returns correct resultspnpm test -- packages/realtime/src/vad/cli-handlers.test.ts— VAD CLI handlers still workpnpm test -- packages/core/src/agent/agent-loop.test.ts— agent loop retry/sleep behavior intactpnpm test -- packages/core/src/tools/code-mode/service.ts— code mode delay/abort behavior intactVerification
pnpm checkpasses (tests: 1152 passed, lint: 0 errors, dep-guard: clean, deadcode: clean, format: clean)Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com