Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ed8d771

Browse files
committedApr 26, 2019
fix(fromFetch): don't abort if fetch resolves
Closes #4739
1 parent 2597e0d commit ed8d771

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎src/internal/observable/dom/fetch.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export function fromFetch(input: string | Request, init?: RequestInit): Observab
5555
const controller = new AbortController();
5656
const signal = controller.signal;
5757
let outerSignalHandler: () => void;
58+
let abortable = true;
5859
let unsubscribed = false;
5960

6061
if (init) {
@@ -73,9 +74,11 @@ export function fromFetch(input: string | Request, init?: RequestInit): Observab
7374
}
7475

7576
fetch(input, init).then(response => {
77+
abortable = false;
7678
subscriber.next(response);
7779
subscriber.complete();
7880
}).catch(err => {
81+
abortable = false;
7982
if (!unsubscribed) {
8083
// Only forward the error if it wasn't an abort.
8184
subscriber.error(err);
@@ -84,7 +87,9 @@ export function fromFetch(input: string | Request, init?: RequestInit): Observab
8487

8588
return () => {
8689
unsubscribed = true;
87-
controller.abort();
90+
if (abortable) {
91+
controller.abort();
92+
}
8893
};
8994
});
9095
}

0 commit comments

Comments
 (0)
Please sign in to comment.