Codebase quality sweep: error handling, drift detection, test hygiene#176
Merged
Conversation
commit: |
- recorder.ts: capture error context in 3 bare catch blocks (URL parse, JSON parse, fixture merge), wrap clientRes.write/end in try/catch to prevent unhandled exceptions on client disconnect - agui-recorder.ts: wrap 4 unguarded stream write/end calls in try/catch, add response termination when headers already sent, capture URL parse error context - server.ts: add response termination to top-level catch when headers already sent, capture JSON parse detail in 400 response, move res.end inside try/catch in 7 error recovery paths - a2a-mock.ts, mcp-mock.ts: add response termination when headers already sent in standalone server catch blocks - vector-mock.ts: guard readBody with method check to prevent double body consumption on passthrough
Capture and surface the actual JSON.parse error message in every request-body parse catch block across all provider handlers, WebSocket handlers, and stream-collapse functions. Previously these returned generic "Malformed JSON" without the parse position or reason. Also add firstDroppedSample field to CollapseResult for stream chunk parse failures, preserving forensic data for debugging. 25 files across all LLM providers, multimedia endpoints, WebSocket handlers, and stream collapse.
skipIf timing - schema.ts compareSSESequences: replace .find() with .filter() + mergeShapes to compare ALL events per type, catching shape variations in subsequent events (e.g., Anthropic thinking deltas) - ollama.drift.ts: replace async OLLAMA_REACHABLE with synchronous process.env.OLLAMA_HOST gate, matching every other drift file
- recorder.test.ts: fix misleading "toolCalls should win" comments and assertions to reflect actual content+toolCalls coexistence; move prototype-level setTimeout spy to afterEach for leak safety - fixture-loader.test.ts, sse-writer.test.ts, mcp-mock.test.ts, metrics.test.ts, chaos.test.ts: add vi.restoreAllMocks() to afterEach for unrestored spy cleanup - ws-framing.test.ts: add closeAllConnections before server.close - 17 test files: update "Malformed JSON" assertions to match new error detail format
fa745bd to
a3d9f95
Compare
3 tasks
jpr5
added a commit
that referenced
this pull request
May 11, 2026
## Summary Follow-up quality sweep addressing 30 issues surfaced by 7-agent CR on PR #175, complementing the broader sweep in #176. **Recorder proxy relay** — forward HTTP method instead of hardcoding POST, clear response timeout after completion, fix client-disconnect handler to check `writableFinished` before destroying upstream, wrap hook callbacks in try/catch, override audio content-type on error relay, atomic fixture writes, toolCall sanitization, tighter video detection **Server error handling** — deferred splice for one-shot error fixtures, SyntaxError guard on Azure injection catch, fixture-level chaos evaluation for non-completions endpoints, fal body double-consumption fix, fal PUT body support **Test hygiene** — tmpDir leak fix, global fetch replaced with node:http helpers, try/finally fixture cleanup, deduplicated helpers, explicit mock properties, resource guard on setup helper ## Test plan - [x] 2872 tests pass (79 files, 37 skipped) - [x] TypeScript typecheck clean - [x] Prettier + ESLint clean
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Codebase-wide quality sweep addressing 6 categories of issues across 53 files:
compareSSESequencesnow compares ALL events per type (not just the first), catching shape variations like Anthropic thinking deltas; Ollama drift tests use synchronous env-var gate instead of broken asyncdescribe.skipIfTest plan