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

Move FormData instantiation inside makeRequest retry #274

Merged
merged 1 commit into from
May 29, 2024

Conversation

lencioni
Copy link
Contributor

I have been troubleshooting a perplexing issue when updating the happo.io package at Airbnb. It seems that on this new version when a request fails and is retried it ends up erroring out with a socket hang up error after 60 seconds.

After some investigation, this error seems to be exactly what was reported here:

node-fetch/node-fetch#1743

The issue is that the FormData instance is being reused but since its buffer is already consumed it puts fetch into a bad state where it never actually sends the request and hangs until it hits a socket timeout of 60 seconds. The proposed fix is to always use a fresh FormData instance.

In this commit I am moving the prepareFormData call to inside of the retry function so that we get a fresh FormData instance on each retry. I am hopeful that this will resolve this issue.

I added a test to cover this behavior. When I run the test before my change I observe that the test suite hangs when making this request. After my change everything works as expected. This makes me fairly confident in the value of this change.

I have been troubleshooting a perplexing issue when updating the
happo.io package at Airbnb. It seems that on this new version when a
request fails and is retried it ends up erroring out with a socket hang
up error after 60 seconds.

After some investigation, this error seems to be exactly what was
reported here:

  node-fetch/node-fetch#1743

The issue is that the `FormData` instance is being reused but since its
buffer is already consumed it puts fetch into a bad state where it never
actually sends the request and hangs until it hits a socket timeout of
60 seconds. The proposed fix is to always use a fresh `FormData`
instance.

In this commit I am moving the prepareFormData call to inside of the
retry function so that we get a fresh FormData instance on each retry. I
am hopeful that this will resolve this issue.

I added a test to cover this behavior. When I run the test before my
change I observe that the test suite hangs when making this request.
After my change everything works as expected. This makes me fairly
confident in the value of this change.
@lencioni lencioni requested a review from trotzig May 29, 2024 15:19
Copy link
Contributor

@trotzig trotzig left a comment

Choose a reason for hiding this comment

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

Thank you @lencioni!

@trotzig trotzig merged commit af91f9d into master May 29, 2024
3 checks passed
@trotzig trotzig deleted the fetch-form-data branch May 29, 2024 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants