Skip to content

Commit 7e9c3f7

Browse files
anthonyfacebook-github-bot
anthony
authored andcommitted
Fix HEAD request failing with Invalid response for blob (#19567)
Summary: Fixes #18223 This is a fairly simple solution to what seems to be a recurring issue where certain requests that result in an empty body where JSON is expected throw an error rather than being handled gracefully. Client side error handling is not being hit as this is being thrown at a lower level. Make a http request that results in an empty blob: "" [INTERNAL] [BUGFIX] [XMLHttpRequest.js] - Line 262 Pull Request resolved: #19567 Differential Revision: D8314416 Pulled By: hramos fbshipit-source-id: a17c49f3620f0abbb936f3a1c2b01aa1b64820fd
1 parent d517214 commit 7e9c3f7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Libraries/Network/XMLHttpRequest.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ class XMLHttpRequest extends EventTarget(...XHR_EVENTS) {
246246
case 'blob':
247247
if (typeof this._response === 'object' && this._response) {
248248
this._cachedResponse = BlobManager.createFromOptions(this._response);
249-
} else {
249+
} else if (this._response === '') {
250+
this._cachedResponse = null;
251+
} else {
250252
throw new Error(`Invalid response for blob: ${this._response}`);
251253
}
252254
break;

0 commit comments

Comments
 (0)