Skip to content

Commit 2b1b14f

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 126efc9 commit 2b1b14f

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
@@ -364,6 +364,7 @@ class HttpResourceImpl<T>
364364
}
365365

366366
send({error});
367+
abortSignal.removeEventListener('abort', onAbort);
367368
},
368369
complete: () => {
369370
if (resolve) {

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

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

7070
sub = opts.loader(params).subscribe({
7171
next: (value) => send({value}),
72-
error: (error) => send({error}),
72+
error: (error) => {
73+
send({error});
74+
params.abortSignal.removeEventListener('abort', onAbort);
75+
},
7376
complete: () => {
7477
if (resolve) {
7578
send({error: new Error('Resource completed before producing a value')});

0 commit comments

Comments
 (0)