Discard writes made to an aborted uWS response #682
Merged
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.
The kind of change this PR does introduce
Current behaviour
This bug only exists for polling transport connections running on top of uWS.
If the remote client abruptly disconnects (thus aborting the request) while the server is waiting on an asynchronous operation such as compression, the server may attempt to write a response via the aborted response object. This causes an uncaught exception to be thrown.
New behaviour
Attempts to write to or finalize the aborted response object are now silently discarded instead. While checking for an aborted response at the writing call site is also an option, I feel this approach is both the least likely to regress down the road, and that the desired behavior would be the same in any case.