Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move FormData instantiation inside makeRequest retry
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.
- Loading branch information