React-native-debugger: Network inspector is broken on RN 0.56

Created on 3 Jul 2018  路  12Comments  路  Source: jhen0409/react-native-debugger

React Native Debugger app version: 0.7.18
React Native version: 0.56-rc.4
Platform: iOS simulator
Is real device of platform: No, simulator
Operating System: macOS 10.13.5

It appears that React Native 0.56 has broken the network inspector. I'm actually not sure if this is an issue with react-native-debugger or Chrome, as it appears that has broken as well. I would be happy to work on a fix if someone could point me in the right direction. Thanks!

bug

Most helpful comment

react-native 0.56 polyfills the global.Blob which breaks the fetch polyfill's strict check, we have to restore the original Blob when using the latest react-native-debugger with react-native > 0.54

if (__DEV__) {
  global.XMLHttpRequest = global.originalXMLHttpRequest ?
    global.originalXMLHttpRequest :
    global.XMLHttpRequest;
  global.FormData = global.originalFormData ?
    global.originalFormData :
    global.FormData;
  global.Blob = global.originalBlob ?
    global.originalBlob :
    global.Blob;
  global.FileReader = global.originalFileReader ?
    global.originalFileReader :
    global.FileReader;
}

All 12 comments

The main issue is #244, it should affect the Network Inspect.

+1, Any solution?

I got it to work temporally by adding this to my project:

// https://github.com/jhen0409/react-native-debugger/issues/242
if (__DEV__) {
  /* eslint no-undef: 0 */
  XMLHttpRequest = GLOBAL.originalXMLHttpRequest
    ? GLOBAL.originalXMLHttpRequest
    : GLOBAL.XMLHttpRequest;
}

react-native 0.56 polyfills the global.Blob which breaks the fetch polyfill's strict check, we have to restore the original Blob when using the latest react-native-debugger with react-native > 0.54

if (__DEV__) {
  global.XMLHttpRequest = global.originalXMLHttpRequest ?
    global.originalXMLHttpRequest :
    global.XMLHttpRequest;
  global.FormData = global.originalFormData ?
    global.originalFormData :
    global.FormData;
  global.Blob = global.originalBlob ?
    global.originalBlob :
    global.Blob;
  global.FileReader = global.originalFileReader ?
    global.originalFileReader :
    global.FileReader;
}

Fixed by #247.

This bug appears to be back with [email protected] this comment fixes it

this is still broken, unfortunately React Native seems to become more and more buggy

I got it to work temporally by adding this to my project:

// https://github.com/jhen0409/react-native-debugger/issues/242
if (__DEV__) {
  /* eslint no-undef: 0 */
  XMLHttpRequest = GLOBAL.originalXMLHttpRequest
    ? GLOBAL.originalXMLHttpRequest
    : GLOBAL.XMLHttpRequest;
}

Where did you put this code?

@hanssonfredrik anywhere as long as it gets run. I put it in a development config file that is loaded in index.js

After adding the code I can see the request but no responses

Does anyone figures out how to fix it?

After adding the code I can see the request but no responses

+1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MailosT picture MailosT  路  4Comments

Clete2 picture Clete2  路  5Comments

cvvspb picture cvvspb  路  3Comments

usrbowe picture usrbowe  路  6Comments

JodiWarren picture JodiWarren  路  3Comments