Skip to content

Commit ed8d771

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

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export function fromFetch(input: string | Request, init?: RequestInit): Observab
5555
constcontroller=newAbortController();
5656
constsignal=controller.signal;
5757
letouterSignalHandler: ()=>void;
58+
letabortable=true;
5859
letunsubscribed=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)