Skip to content

Commit

Permalink
refactor: internal logic fix in the multicast channel code (no public…
Browse files Browse the repository at this point in the history
… behavior impact) - ensure to mark a channel's iterator as closed for further pull attempts as soon as it realizes its parent channel itself had already ended/errored out (#47)
  • Loading branch information
shtaif authored Oct 4, 2023
1 parent 83393f6 commit d11a74b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/utils/createMulticastChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ function createMulticastChannel<T>(): MulticastChannel<T> {
return { done: false, value: listHead.item };
}

if (channelState === ChannelInternalState.CLOSED) {
return { done: true, value: undefined };
}

if (channelState === ChannelInternalState.ERROR) {
if (channelState !== ChannelInternalState.ACTIVE) {
isIteratorClosed = true;
if (channelState === ChannelInternalState.CLOSED) {
return { done: true, value: undefined };
}
throw channelErrorValue;
}

Expand Down

0 comments on commit d11a74b

Please sign in to comment.