Skip to content

Commit

Permalink
fix panic when Unfold sink return an error
Browse files Browse the repository at this point in the history
  - fix issue rust-lang#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 committed Jan 14, 2023
1 parent 0203cde commit 5c0bc08
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 5c0bc08

Please sign in to comment.