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

[ACT-242] Remove response.clone() to fix issue with node-fetch where response hangs #822

Closed
wants to merge 7 commits into from

Conversation

valerieernst
Copy link
Contributor

@valerieernst valerieernst commented Oct 17, 2022

A summary of your pull request, including the what change you're making and why.

Why?

There is an issue in node-fetch < 3.0.0 that causes responses larger than 16kb to hang when cloned. We use cross-fetch, which has no plans to upgrade node-fetch to a version where this is resolved.

We want to allow responses with bodies larger than 16kb, so we need cannot use .clone() in our middleware. However, we want to continue reading the response stream in the middleware so we can handle json appropriately. Since we're reading the body in the middleware, we cannot read it again in downstream code. To prevent this, we strip the methods from the ModifiedResponse type.

What?

  • No longer clones responses in the middleware
  • Updates usage of Body methods (.json() and text()) to use the data property on the ModifiedResponse
  • Adds return types to the requests based on current usage of the code to prevent ts errors

Testing

Include any additional information about the testing you have completed to
ensure your changes behave as expected. For a speedy review, please check
any of the tasks you completed below during your testing.

  • Added unit tests for new functionality
  • Tested end-to-end using the local server
  • [Segmenters] Tested in the staging environment

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