question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fetch implementation does not support streams from the spec - needs implementation in React Native core

See original GitHub issue

React Native has not implemented fetch on top of native APIs, and the fetch polyfill built on top of XHR does not support streams where response.body is a getter for a ReadableStream.

React Native version:

0.61.4

Steps To Reproduce

Use fetch and see that response.body is undefined rather than a getter for a ReadableStream according the the fetch spec.

Describe what you expected to happen:

I expected for response.body to be defined.

Related issues

https://github.com/facebook/react-native/issues/9629 https://github.com/facebook/react-native/issues/12912 https://github.com/github/fetch/issues/746#issuecomment-573251497 (cc @MattiasBuelens)

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:11
  • Comments:16 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
tom-shermancommented, May 31, 2022

I am really interested in bringing spec-compliant fetch to react native. I think there’s renewed interest in the OSS community and JS developers to standardise where possible as seen in adding fetch to node.js core and the work Cloudflare, Vercel, Shopify et al are doing in WinterCG.

A spec compliant fetch also aligns with React Native’s goals IMO.

Has there been any discussion in how to bring spec compliant fetch to React Native? The polyfill fork is a good start but I’m not sure the caveats especially around performance and bundle size make it suitable for general adoption.

2reactions
cpojercommented, Mar 10, 2020

The Facebook GitHub org only contains project managed by Facebook. It’ll mean we have to take care of releases and everything. I’m not sure if that’s a good idea, you’ll probably be able to move faster on a separate org. What about react-native-community? @alloy can get you set up with that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Fetch API is finally coming to Node.js - LogRocket Blog
It's been a long time coming, but the Fetch API is now available in Node.js core. Learn why it took so long and...
Read more >
Networking - React Native
React Native provides the Fetch API for your networking needs. Fetch will seem familiar if you have used XMLHttpRequest or other networking APIs ......
Read more >
Suspense for Data Fetching (Experimental) - React
It is not a data fetching implementation. ... As data streams in, React retries rendering components that still need data until they're all...
Read more >
node-fetch - npm
Instead of implementing XMLHttpRequest in Node.js to run ... iterators with streams did not mature until Node.js 14, so you need to do...
Read more >
Web Streams Everywhere (and Fetch for Node.js) - CSS-Tricks
As the spec says, A readable stream can be piped directly to a writable ... Unlike browsers, Node core doesn't currently implement fetch....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found