http: fix writableFinished and 'finish' after write errors - #64847
Open
pimterry wants to merge 1 commit into
Open
http: fix writableFinished and 'finish' after write errors#64847pimterry wants to merge 1 commit into
pimterry wants to merge 1 commit into
Conversation
Only emit 'finish' and set writableFinished once all data has actually been flushed successfully. end() callbacks now report the outcome like stream.Writable: called with null on finish, or with the error that prevented the flush. Signed-off-by: Tim Perry <pimterry@gmail.com>
Collaborator
|
Review requested:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #64847 +/- ##
==========================================
- Coverage 90.17% 90.16% -0.02%
==========================================
Files 746 746
Lines 242776 242814 +38
Branches 45741 45755 +14
==========================================
+ Hits 218929 218930 +1
- Misses 15347 15375 +28
- Partials 8500 8509 +9
🚀 New features to boost your workflow:
|
metcoder95
approved these changes
Jul 31, 2026
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.
On HTTP OutgoingMessages, only emit 'finish' and set writableFinished once all data has actually been flushed successfully, and make end() callbacks report the correct outcome like stream.Writable: called with null on finish, or with the error that prevented the flush.
This changes visible behaviour in some subtle ways, but I think exclusively in a more correct direction, which matches
Writableeverywhere else and matches the existing docs. Now, if an HTTP write calls end() but fails to actually flush the data, it will fail to finish, and theend()callback behaviour correctly matches. See the 2 tests that need changing here due to subtle changes in ordering & finish behaviour.It's on the line, but I'd really rather not make this semver major because it's a prerequisite for #64566 fixing #64272. That's a regression on v24 & v26 today, due to changes in how libuv exposes ECONNRESET. To work around that change, we need an accurate signal for writableFinished, and we currently don't have one.