diff --git a/src/utils/createMulticastChannel.ts b/src/utils/createMulticastChannel.ts index d4fbe79..2d603f1 100644 --- a/src/utils/createMulticastChannel.ts +++ b/src/utils/createMulticastChannel.ts @@ -66,11 +66,11 @@ function createMulticastChannel(): MulticastChannel { 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; }