Skip to content
Permalink
Browse files

fix(fromFetch): don't abort if fetch resolves

Closes #4739
  • Loading branch information...
cartant committed Apr 26, 2019
1 parent 2597e0d commit ed8d77157868a681e1e3416e9b13b09052f1b6f7
Showing with 6 additions and 1 deletion.
  1. +6 −1 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();
}
};
});
}

0 comments on commit ed8d771

Please sign in to comment.
You can’t perform that action at this time.