Skip to content

Commit 3b385a1

Browse files
kostasmanionisrobrichard
authored andcommitted
Trigger onError when a connection is dropped (#1)
1 parent 3b60a72 commit 3b385a1

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/fetch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ export function fetchImpl(url, { method, headers, body, onNext, onError, onCompl
3838
onComplete();
3939
});
4040
}
41-
});
41+
}).catch(onError);
4242
}

src/xhr.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ export function xhrImpl(url, { method, headers, body, onNext, onError, onComplet
1919
const patchResolver = new PatchResolver({ onResponse: r => onNext(r) });
2020

2121
function onReadyStateChange() {
22+
// The request failed, do nothing and let the error event fire
23+
if (this.readyState === this.DONE && this.status === 0) {
24+
return;
25+
}
26+
2227
if (this.readyState === this.HEADERS_RECEIVED) {
2328
const contentType = xhr.getResponseHeader('Content-Type');
2429
if (contentType.indexOf('multipart/mixed') >= 0) {

0 commit comments

Comments
 (0)