Skip to content

Commit

Permalink
fix one-tick-race condition in asyncMap
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Sep 25, 2023
1 parent 770cb72 commit 7e0695a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/utilities/observables/asyncMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,21 @@ export function asyncMap<V, R>(
.then(both, both)
.then(
(result) => {
--activeCallbackCount;
next && next.call(observer, result);
if (completed) {
handler.complete!();
}
},
(error) => {
--activeCallbackCount;
throw error;
}
)
.catch((caught) => {
error && error.call(observer, caught);
});
promiseQueue.finally(() => {
--activeCallbackCount;
if (completed) {
handler.complete!();
}
});
};
} else {
return (arg) => delegate && delegate.call(observer, arg);
Expand Down

0 comments on commit 7e0695a

Please sign in to comment.