Skip to content

Commit

Permalink
fix panic when Unfold sink return an error (#2686)
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
erebe authored and taiki-e committed Jan 30, 2023
1 parent eb68070 commit 71f7b78
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion futures-util/src/sink/unfold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ where
this.state.set(UnfoldState::Value { value: state });
Ok(())
}
Err(err) => Err(err),
Err(err) => {
this.state.set(UnfoldState::Empty);
Err(err)
}
}
} else {
Ok(())
Expand Down

0 comments on commit 71f7b78

Please sign in to comment.