Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Consume body on non 200 requests #338

Merged
merged 1 commit into from
Dec 1, 2023
Merged

Conversation

trygve-lie
Copy link
Contributor

Theoretically this should fix the SocketError: other side closed errors we are seeing.

Based on the theory that the body of a request must be consumed or destroyed it seems to me that for requests which yield a HTTP 200 (successful) response we are consuming the body while for request which yields a non HTTP 200 (unsuccessful) response we are not.

Non HTTP 200 responses do have a body too.

This consumes the body on non HTTP 200 responses. Consuming the body over destroying the stream is done because destroying the stream will trigger a socket error which causes a termination of the request differently that what we want when the upstream service is yielding http errors.

Copy link
Member

@digitalsadhu digitalsadhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've now tested this locally and it does very much appear to fix the issue. I can't get the server to crash anymore.

@digitalsadhu digitalsadhu merged commit 8e3ab0e into master Dec 1, 2023
7 checks passed
@digitalsadhu digitalsadhu deleted the fix-socket-error branch December 1, 2023 19:26
Copy link

github-actions bot commented Dec 1, 2023

🎉 This PR is included in version 5.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants