[0.54 - iOS] fetch HEAD requests fail with `Invalid response for blob`
See original GitHub issuePerforming a HEAD
request with fetch
causes an Invalid response for blob
error on iOS
Environment
Environment: OS: macOS Sierra 10.12.6 Node: 8.6.0 Yarn: Not Found npm: 5.3.0 Watchman: 4.9.0 Xcode: Xcode 9.1 Build version 9B55 Android Studio: 3.0 AI-171.4443003
Packages: (wanted => installed) react: 16.3.0-alpha.1 => 16.3.0-alpha.1 react-native: 0.54.0 => 0.54.0
Expected Behavior
The request should complete without error.
Actual Behavior
The RCTNetworking native module in iOS does not construct an empty blob for HEAD
responses like Android does. Instead it returns an empty string as the response. However, whatwg-fetch
always sets the responseType
to blob
for the XMLHttpRequest so the empty string is invalid.
Relevant lines of code: https://github.com/github/fetch/blob/fcc4e1b48cfb5a2b1625fcd6eac06d954b00ccb6/fetch.js#L454 https://github.com/facebook/react-native/blob/6eef7de46ee5c5004854c1cdd5cd83f2a608f622/Libraries/Network/XMLHttpRequest.js#L253-L258
Invalid response for blob:
handleException @ index.bundle?platform=ios&dev=true&minify=false:13132
handleError @ index.bundle?platform=ios&dev=true&minify=false:12174
reportFatalError @ index.bundle?platform=ios&dev=true&minify=false:783
__guardSafe @ index.bundle?platform=ios&dev=true&minify=false:2360
callFunctionReturnFlushedQueue @ index.bundle?platform=ios&dev=true&minify=false:2165
t @ RNDebuggerWorker.js:1
Steps to Reproduce
1 Clone and run https://github.com/lingokids/FetchError
(I tested on an iPhone 7)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:54
- Comments:73 (10 by maintainers)
+1
cc @grabbou f5207ba9c764f33ef83fa897f6014d67193be0e2 might be worth cherry-picking into 0.54 and 0.55