fix: replace finished() with writable lifecycle tracking#5001
Draft
trivikr wants to merge 1 commit intonodejs:mainfrom
Draft
fix: replace finished() with writable lifecycle tracking#5001trivikr wants to merge 1 commit intonodejs:mainfrom
trivikr wants to merge 1 commit intonodejs:mainfrom
Conversation
Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5001 +/- ##
==========================================
- Coverage 92.93% 92.92% -0.02%
==========================================
Files 110 110
Lines 35735 35781 +46
==========================================
+ Hits 33210 33249 +39
- Misses 2525 2532 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
This relates to...
lib/api/api-stream.jsstream.finished()inStreamHandlerRationale
StreamHandlerusedstream.finished(res, { readable: false })to observe completion of the user-provided writable. That helper is broader than this path needs and registers extra listeners, which adds avoidable overhead on a hot path.This change narrows lifecycle tracking to the writable side only while preserving the behavior
stream()depends on for completion, writable errors, and premature close handling.Changes
stream.finished()usage inStreamHandlerwith a small writable lifecycle helper that listens only forfinish,error, andcloseERR_STREAM_PREMATURE_CLOSEwhen the writable closes before finishing'error'event, which keeps existing error handling semantics intactFeatures
N/A
Bug Fixes
stream()response handlingstream()callback and abort behavior consistent for writable finish, error, and premature close edge casesBreaking Changes and Deprecations
Status