Skip to content

Close zipped and cycled streams properly on errors - #16135

Merged
josevalim merged 2 commits into
elixir-lang:mainfrom
mandar1045:fix-stream-zip-cycle-cleanup
Nov 14, 2026
Merged

josevalim merged 2 commits into
elixir-lang:mainfrom
mandar1045:fix-stream-zip-cycle-cleanup

Conversation

@mandar1045

Copy link
Copy Markdown
Contributor

Closes #16134.

When the consumer or one of the zipped streams raises, Stream.zip/zip_with now close the streams in their current state instead of the previous step's continuations, so resources are not started again just to be closed, after_fun runs once, and it gets the current acc. Stream.cycle now halts the suspended inner stream when the consumer raises.

The new tests fail on main and pass with this change.

Signed-off-by: Mandar Joshi <mandarjoshi1045@gmail.com>
Comment thread lib/elixir/lib/stream/reducers.ex Resolved
@josevalim
josevalim merged commit da67814 into elixir-lang:main Nov 14, 2026
15 checks passed
@mandar1045
mandar1045 deleted the fix-stream-zip-cycle-cleanup branch November 14, 2026 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Stream.zip and Stream.cycle don't close resources properly when the consumer raises

2 participants