Skip to content

[0.54 - iOS] fetch HEAD requests fail with Invalid response for blob #18223

Closed
@awinograd

Description

@awinograd

Performing 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

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}`);
}

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)

Metadata

Metadata

Labels

Impact: RegressionDescribes a behavior that used to work on a prior release, but stopped working recently.Issue: Author Provided ReproThis issue can be reproduced in Snack or an attached project.Platform: iOSiOS applications.Resolution: LockedThis issue was locked by the bot.Resolution: PR SubmittedA pull request with a fix has been provided.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions