Skip to content

Commit 93e8565

Browse files
arturovtthePunderWoman
authored andcommitted
fix(core): cleanup rxResource abort listener (#58306)
The observable terminates immediately when `error` is called, and no further emissions or completion notifications occur. Thus, we have to remove the `abort` listener in both the `error` and `complete` notifications. PR Close #58306
1 parent 1650a85 commit 93e8565

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

packages/common/http/src/resource.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ class HttpResourceImpl<T>
359359
}
360360

361361
send({error});
362+
abortSignal.removeEventListener('abort', onAbort);
362363
},
363364
complete: () => {
364365
if (resolve) {

packages/core/rxjs-interop/src/rx_resource.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ export function rxResource<T, R>(opts: RxResourceOptions<T, R>): ResourceRef<T |
8282

8383
sub = streamFn(params).subscribe({
8484
next: (value) => send({value}),
85-
error: (error) => send({error}),
85+
error: (error) => {
86+
send({error});
87+
params.abortSignal.removeEventListener('abort', onAbort);
88+
},
8689
complete: () => {
8790
if (resolve) {
8891
send({

0 commit comments

Comments
 (0)