@@ -230,6 +230,7 @@ processHeap q heap st sv winfo entry sno stopping = loopHeap sno entry
230230
231231 loopHeap seqNo ent =
232232 case ent of
233+ AheadEntryNull -> nextHeap seqNo
233234 AheadEntryPure a -> do
234235 -- Use 'send' directly so that we do not account this in worker
235236 -- latency as this will not be the real latency.
@@ -338,7 +339,12 @@ processWithoutToken q heap st sv winfo m sno = do
338339 -- we have already decremented the yield limit for m
339340 let stop = do
340341 liftIO (incrementYieldLimit sv)
341− workLoopAhead q heap st sv winfo
342+ -- If the stream stops without yielding anything, and we do not put
343+ -- anything on heap, but if heap was waiting for this seq number
344+ -- then it will keep waiting forever, because we are never going to
345+ -- put it on heap. So we have to put a null entry on heap even when
346+ -- we stop.
347+ toHeap sno AheadEntryNull
342348
343349 unStream m st stop (singleToHeap sno) (yieldToHeap sno)
344350