Repository navigation
fix: clean up JSON streams replaced by null - #2014
Aurantium-47 wants to merge 1 commit into
Conversation
Call the existing stream cleanup before returning the serialized JSON null body. Assisted-by: OpenAI GPT-6 <noreply@openai.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The change cleans up the replaced stream while preserving the JSON null response. No merge-blocking risk remains in the reviewed change. Pre-merge checks |
|
Reviewer's GuideThe fix updates JSON body replacement to clean up an existing response stream before returning, while preserving the established null serialization and response metadata. New regression tests verify cleanup for both null and undefined replacements and confirm the resulting body, status, and content type. Sequence diagram for JSON response body replacement cleanupsequenceDiagram
participant Caller
participant Response
participant PreviousStream
Caller->>Response: body replacement with null or undefined
Response->>Response: cleanupPreviousStream()
Response->>Response: set _body to null
Response-->>Caller: return
PreviousStream-->>Response: stream is cleaned up
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2014 +/- ##
=======================================
Coverage 99.90% 99.90%
=======================================
Files 9 9
Lines 2144 2145 +1
=======================================
+ Hits 2142 2143 +1
Misses 2 2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
When a Node.js response stream has
Content-Type: application/json, replacing it withnullorundefinedserializes the JSON body as'null'and returns before cleaning up the old stream. The abandoned stream stays alive until the response finishes, unlike other non-stream body replacements.Call the existing cleanup helper before this return. Regression tests cover both values and check that the JSON body, status and content type are preserved.
Validation on Windows with Node.js 24.15.0 / npm 11.12.1:
node --test __tests__/response/body.test.js: 36 passed.npm run test:coverage: 468 passed, 0 failed or skipped.npm run lintandgit diff --check: passed.AI assistance: implemented and tested with OpenAI GPT-6.
Checklist
No commitlint command or configuration is present in this checkout; the commit uses the existing
fix:convention.Summary by Sourcery
Ensure JSON stream replacements with null or undefined clean up the previous stream before returning.
Bug Fixes:
Tests:
Summary by CodeRabbit
nullorundefinedin a non-empty JSON response now serializes the body asnulland properly closes the original stream. The response retains its status and JSON content type. This prevents the previous stream from being left open when the JSON body is replaced.