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.

XHR fails with "Invalid response for blob" on Android

See original GitHub issue

React crash on fetch, Android only Similar to https://github.com/facebook/react-native/issues/18223 (but this is only ios) Similar to https://github.com/facebook/react-native/issues/18190 (but my response is not empty and the response code is 200)

Environment

Environment: OS: macOS High Sierra 10.13.3 Node: 9.6.1 Yarn: 1.5.0 npm: 5.6.0 Watchman: 4.9.0 Xcode: Xcode 9.2 Build version 9C40b Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed) react: 16.2.0 => 16.2.0 react-native: 0.54.0 => 0.54.0

Steps to Reproduce

that’s enough to crash on Android (it works all right on ios) Emulated on google Pixel android 27

fetch(https://crypto-viewer.rebeleo.com/updates/en-US/android) .then(res => res.json()) .then(data => ({ data })) .catch(err => { alert('Something went wrong with the Updatesfeed 😦 => ’ + err) return { err } })

Expected Behavior

Expect the type of the response to be seen as json

Actual Behavior

This is a regression issue. The response is seen as empty, and as blob

screenshot_1521418646

// Is going in this branch case ‘blob’: if (typeof this._response === ‘object’ && this._response) { this._cachedResponse = BlobManager.createFromOptions(this._response); } else { throw new Error(Invalid response for blob: ${this._response}); } break;

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:21
  • Comments:79 (11 by maintainers)

github_iconTop GitHub Comments

6reactions
satya164commented, May 14, 2018

@tmaly1980: Why is this still a problem when there’s a clear solution?

Because nobody has provided a way to reproduce this bug and there’s no way to test whatever fix we do actually works.

6reactions
TheSaviorcommented, Apr 1, 2018

@satya164

Here is a repro:

https://github.com/TheSavior/react-native-blob-repro

The relevant lines are the server:

app.post('/', (req, res) => res.end('', 'binary'));

and the react-native app:

fetch('http://localhost:8798', {method: 'POST'});
Read more comments on GitHub >

github_iconTop Results From Across the Web

"Invalid response for blob" Error When Making XHR Request
Whilst making a request to one of my API endpoints for an iOS application, I came across a very unhelpful error: "Invalid response...
Read more >
Uploading blob with XMLHttpRequest doesn't work in Android
I'm using Firestore v9 within Expo/React Native. I use XMLHttpRequest to convert a base64 image into a blob file.
Read more >
52486 - Implement XHR.responseType='blob' - chromium
Prepares the XHR to make the response available as a blob object. ... Throws INVALID_STATE_ERR if set at an invalid time. Maybe read...
Read more >
XMLHttpRequest Standard
response type: One of the empty string, " arraybuffer ", " blob ", " document ", " json ...
Read more >
XMLHttpRequest.responseType - Web APIs | MDN
The XMLHttpRequest property responseType is an enumerated string value ... The response is a Blob object containing the binary data.
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