fetch icon indicating copy to clipboard operation
fetch copied to clipboard

fix: clone methods correctly handle teeing body stream

Open slightlytyler opened this issue 2 years ago • 2 comments

Encountered error This stream has already been locked for exclusive reading by another reader when cloning a response that gets read as a stream. Problem was we did not handle teeing the body stream when cloning happens. The fix is:

  1. Response/Request clone method creates a new instance with a null body
  2. Source body is cloned
  3. Body clone method tees stream, sets its stream to one output, and returns a body with second output
  4. Response/Request clone sets body on cloned instance
  5. Response/Request clone returns new instance

Also added a few updates to correct the behavior of this library wrt the spec. Namely body class handles explicitly null bodyInit and request/response clone methods check if the body has been used before executing.

Test cases added / modified to verify the new cloning behavior

slightlytyler avatar Jun 05 '23 23:06 slightlytyler

Was hoping the tests would work in CI since I can't get them to run locally but looks like they're running into similar environment problems

slightlytyler avatar Jun 05 '23 23:06 slightlytyler

@acostalima are you still maintaining? Code here is good to go but the test infra is broken locally and in CI. I got it working locally by editing the generated rn test app but unsure of what the real fix is. seems like a problem with react-native-test-runner rather than config in this project though? happy to do whatever needed to get this merged in 👍

slightlytyler avatar Jun 07 '23 21:06 slightlytyler