Skip to content

Fix duplicate elements emitted by timeoutWith after timeout fires#3709

Open
ankitkumarrain wants to merge 4 commits intotypelevel:mainfrom
ankitkumarrain:fix/timeoutOnPullTo-duplicate-elements
Open

Fix duplicate elements emitted by timeoutWith after timeout fires#3709
ankitkumarrain wants to merge 4 commits intotypelevel:mainfrom
ankitkumarrain:fix/timeoutOnPullTo-duplicate-elements

Conversation

@ankitkumarrain
Copy link
Copy Markdown
Contributor

@ankitkumarrain ankitkumarrain commented Apr 6, 2026

I found this bug on running sbt test , this is a flaky bug.

In def Timeoutwith, the merge in timed buffers data chunks concurrently, and the timeout handler passes these buffered chunks to both the timeout function f and the normal go loop. Because of this, timeoutOnPullTo ,timeoutOnPullWithand, timeoutWith can emit duplicate elements after a timeout fires.

Changes made in stream.scala

I made a fix introducing skipStaleTimeouts which skips any further queued timeouts and resumes normal processing with the first data chunk. This will prevent duplicate emission in timeoutOnPullTo and timeoutOnPullWith.

@ankitkumarrain ankitkumarrain changed the title made a fix Fix duplicate elements emitted by timeoutWith after timeout fires Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant