Skip to content

Commit

Permalink
set injector to NeedHandshake state on unexpected errror
Browse files Browse the repository at this point in the history
  • Loading branch information
MarinPostma committed Nov 23, 2023
1 parent 7aa3ddb commit 42b1a56
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libsql-replication/src/replicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,12 @@ impl<C: ReplicatorClient> Replicator<C> {
ReplicatorState::NeedHandshake
}
Err(Error::NeedSnapshot) => ReplicatorState::NeedSnapshot,
Err(e) => return Err(e),
Err(e) => {
// an error here could be due to a disconnection, it's safe to rollback to a
// NeedHandshake state again, to avoid entering a busy loop.
self.state = ReplicatorState::NeedHandshake;
return Err(e);
}
};

Ok(())
Expand Down

0 comments on commit 42b1a56

Please sign in to comment.