Skip to content

Commit

Permalink
Amend resolve bugs in flatMap pr
Browse files Browse the repository at this point in the history
 * loosing values due to using .next while still waiting for outer iterator
 * adding completed iterator to race resulting in exception
  • Loading branch information
thepont committed Oct 8, 2024
1 parent 752157f commit 8f90bc7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/asynciterable/operators/_flatten.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,10 @@ export class FlattenConcurrentAsyncIterable<TSource, TResult> extends AsyncItera
}
case Type.INNER: {
--active;
// add the outer iterator to the race
results[0] = outer.next();
// add the outer iterator to the race, if its been removed and we are not yet done with it
if (results[0] === NEVER_PROMISE && !outerComplete) {
results[0] = outer.next();
}
// return the current slot to the pool
innerIndices.push(index);
// synchronously drain the `outerValues` buffer
Expand Down

0 comments on commit 8f90bc7

Please sign in to comment.