react-native-debugger icon indicating copy to clipboard operation
react-native-debugger copied to clipboard

Unsupported BodyInit type - RN 0.54

Open maxhungry opened this issue 6 years ago • 50 comments

With React Native 0.54, when the option Enable Network Inspect is turned on, you would get Uncaught Error: unsupported BodyInit type, this may have something to do with how blobs changed in 0.54.

React Native Debugger app version: 0.7.13 React Native version: 0.54.1 Platform: iOS & Android Is real device of platform: Yes Operating System: macOS

maxhungry avatar Mar 12 '18 22:03 maxhungry

I"m getting the same issue.

ifiokjr avatar Mar 13 '18 14:03 ifiokjr

I’m seeing this issue with plain Chrome.app DevTools as well btw, so not just an issue with this app.

alloy avatar Mar 13 '18 14:03 alloy

React native bugs. Not debugger.

Lxxyx avatar Mar 14 '18 13:03 Lxxyx

maybe this could help https://github.com/Kureev/react-native-network-proxy

sibelius avatar Mar 15 '18 11:03 sibelius

Fixed in #217. I'll release the new version later.

jhen0409 avatar Mar 16 '18 10:03 jhen0409

Unfortunately I’m still running into the same issue (I’m on RN 0.54.2 btw)

Alas I don’t have time to debug right away, but if this turns out to work for most other people then I’ll definitely try to find some time to debug on our end.

alloy avatar Mar 16 '18 14:03 alloy

Thank you for pushing this fix so quickly!

I'm running 0.7.16 which should have fixed this issue with #217, but I am still seeing the same error as above. Let me know if I can help resolve this.

RN 0.54.2 Android development, actual device. MacOS

jehartzog avatar Mar 16 '18 16:03 jehartzog

Interestingly it works for me if I enable the network inspector after the first request.

alloy avatar Mar 16 '18 19:03 alloy

Due to we call the method after import application script, so some fetch calls on global scope will be failed.

I just realized this mistake 🙈, I guess it may be the same as your case. @alloy @jehartzog

jhen0409 avatar Mar 17 '18 06:03 jhen0409

Just gave it a try and unfortunately it does not work for me. I am running 0.7.17 and RN 0.54.2. Also toggling the inspection after the first request as described by @alloy doesn't work.

Let me know if I can help.

toytonic avatar Mar 19 '18 10:03 toytonic

@toytonic could you provide an example code?

jhen0409 avatar Mar 19 '18 11:03 jhen0409

I must correct myself. Toggling after the first request DOES indeed work. Apparently there was an server issue on our end when debugging this. Sorry for the confusion.

However the issue persists when toggling it on before the first request or after a live reload.

We are using this library for our requests: https://github.com/KnisterPeter/pretend

Which internally just uses the (native) fetch api.

toytonic avatar Mar 19 '18 11:03 toytonic

Just gave the update a try and I’m also still seeing the problem under certain conditions:

  1. Launch app
  2. Enable Network Inspect
  3. Open first RN view that makes a fetch
  4. Receive Unsupported BodyInit type error on all views that make fetches
  5. Reload JS (Command-R)
  6. Now all fetches keep working

You can try this with the example app in our RN repo, but you will need to create an account with artsy.net

alloy avatar Mar 19 '18 12:03 alloy

Thanks for the examples!

I think the issue of first request wil be fixed by https://github.com/jhen0409/react-native-debugger/commit/792549a400329159fbd768439b2d2f02a95f5095. I haven't yet release a new version but you can try it first by follow the documentation. Let me know if it's fixed for you.

jhen0409 avatar Mar 19 '18 16:03 jhen0409

Yup that’s it! Works perfect now 👍

Thanks for the fast fixes 👏

alloy avatar Mar 19 '18 20:03 alloy

@jhen0409 any plan to get a release for this fix?

sibelius avatar Apr 06 '18 19:04 sibelius

@sibelius I think v0.7.18 already included my all fixes, is that still have the bug for you?

jhen0409 avatar Apr 07 '18 02:04 jhen0409

this is breaking on 0.7.18

when we add this to our entry .js file

global.XMLHttpRequest = global.originalXMLHttpRequest ?
  global.originalXMLHttpRequest :
  global.XMLHttpRequest;
global.FormData = global.originalFormData ?
  global.originalFormData :
  global.FormData;

without this, it works, but we can't inspect network

sibelius avatar Apr 07 '18 15:04 sibelius

We are also seeing this issue still. @sibelius comment works, however, we can't see the network requests either.

tzilist avatar Apr 09 '18 18:04 tzilist

@sibelius I removed such code from our codebase and instead started using the contextual menu in the debugger app to enable network inspecting.

alloy avatar Apr 09 '18 22:04 alloy

image

this is the contextual menu, gonna try again, and let your guys know

sibelius avatar Apr 09 '18 22:04 sibelius

I have an issue with 0.7.18 version, If I enable "Network inspect" in contextual menu. fetch.js:231 Uncaught Error: unsupported BodyInit type

react-native: 0.55.2 OS: Ubuntu 17.10

kholiavko-roman avatar Apr 10 '18 14:04 kholiavko-roman

Same issue with react-native-debugger 0.7.18, react-native 0.55.2, macOS 10.13.4

Freddy03h avatar Apr 10 '18 15:04 Freddy03h

@alloy's solution worked for me as well

sedvardsen avatar Apr 11 '18 06:04 sedvardsen

One possible difference I have been noticing is that maybe it’s due to RN version? We’re on RN 0.54

alloy avatar Apr 11 '18 13:04 alloy

After the query,

body = Blob {size: 609, type: "application/json"}

And the conditional its not able to match its prototype,

screen shot 2018-04-15 at 20 59 30

kikoseijo avatar Apr 15 '18 19:04 kikoseijo

Still seeing the issue in 0.54.4, fails if the network inspector is enabled from load, doesn't log any network activity if enabled post launch.

fr1n63 avatar Apr 18 '18 11:04 fr1n63

i can see this issue after i updated from 0.48.2 to 0.55.3

Anshiii avatar Apr 19 '18 09:04 Anshiii

react-native:0.55.3 React Native Debugger 0.7.18 I can see this issue after i updated rn from 0.48.2 to 0.55.3...
And then , i see the code where error be throw in fetch.js... So i do this...

fetch(url, {
      method: 'GET',,
      headers,
      body:' ' //the code i added
    }

And then enable the network... Luckily,everything were be ok~~ What is intriguing is that after i deleted the code body:' ' ,there is no error more.

Anshiii avatar Apr 26 '18 14:04 Anshiii

this is working for on 0.53.3 using this https://github.com/jhen0409/react-native-debugger/issues/209#issuecomment-379917990

sibelius avatar Apr 26 '18 14:04 sibelius