From ed8d77157868a681e1e3416e9b13b09052f1b6f7 Mon Sep 17 00:00:00 2001 From: Nicholas Jamieson Date: Sat, 27 Apr 2019 08:31:51 +1000 Subject: [PATCH] fix(fromFetch): don't abort if fetch resolves Closes #4739 --- src/internal/observable/dom/fetch.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/internal/observable/dom/fetch.ts b/src/internal/observable/dom/fetch.ts index 3513ea0803..22953d9767 100644 --- a/src/internal/observable/dom/fetch.ts +++ b/src/internal/observable/dom/fetch.ts @@ -55,6 +55,7 @@ export function fromFetch(input: string | Request, init?: RequestInit): Observab const controller = new AbortController(); const signal = controller.signal; let outerSignalHandler: () => void; + let abortable = true; let unsubscribed = false; if (init) { @@ -73,9 +74,11 @@ export function fromFetch(input: string | Request, init?: RequestInit): Observab } fetch(input, init).then(response => { + abortable = false; subscriber.next(response); subscriber.complete(); }).catch(err => { + abortable = false; if (!unsubscribed) { // Only forward the error if it wasn't an abort. subscriber.error(err); @@ -84,7 +87,9 @@ export function fromFetch(input: string | Request, init?: RequestInit): Observab return () => { unsubscribed = true; - controller.abort(); + if (abortable) { + controller.abort(); + } }; }); }