Skip to content

Commit c420551

Browse files
authored
fix panic when Unfold sink return an error (#2686)
- fix issue #2600. When an Unfold sink return an error it is left in an invalid state. Calling after that flush/close cause the sink to panic due to re-calling a future already completed. This patch aims to leave the sink in a valid state and allow calling flush/close without causing a panic.
1 parent 0203cde commit c420551

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

futures-util/src/sink/unfold.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ where
7373
this.state.set(UnfoldState::Value { value: state });
7474
Ok(())
7575
}
76-
Err(err) => Err(err),
76+
Err(err) => {
77+
this.state.set(UnfoldState::Empty);
78+
Err(err)
79+
}
7780
}
7881
} else {
7982
Ok(())

0 commit comments

Comments
 (0)