fetch icon indicating copy to clipboard operation
fetch copied to clipboard

Cannot getReader of ReadableStream

Open robinsadeghpour opened this issue 11 months ago • 3 comments

Hey,

I cannot get the reader from the readableStream I get following Error: Error: [TypeError: This stream has already been locked for exclusive reading by another reader]

I also have added the auto import for the polyfills to the root _layout.tsx as I use filebased routing. import 'react-native-polyfill-globals/auto';

const res = await fetch("https://www.lotti.ai/api/lotti", {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Connection: "keep-alive",
        },
        mode: "cors",
        body: JSON.stringify(message),
        "reactNative": { textStreaming: true }
      })

      const reader = res.body?.getReader();
image

I should also mention that the type for reactNative: {textStreaming: true} seems to not be detected correctly: image

robinsadeghpour avatar Mar 25 '24 13:03 robinsadeghpour

The solution is: npm install [email protected] Because the latest version of web-streams-polyfill (4.x) only has polyfill of ES5. But the repo is using ES6 polyfill.

hhjin avatar Jun 21 '24 11:06 hhjin

@robinsadeghpour did you find a solution?

dimonnwc3 avatar Jun 29 '24 17:06 dimonnwc3

All solutions shared doesn't work. Body obj doesn't have stream support in hermes.

djaffer avatar Jul 17 '24 07:07 djaffer