Skip to content

Commit

Permalink
fix: Initiate state before recovering from snapshot (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderTar authored Dec 15, 2023
1 parent 2565190 commit 5c5234f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@ func (entity *actor[T]) recoverFromSnapshot(ctx context.Context) error {
// we do have the latest state just recover from it
if event != nil {
// set the current state
if err := event.GetResultingState().UnmarshalTo(entity.currentState); err != nil {
currentState := entity.InitialState()
if err := event.GetResultingState().UnmarshalTo(currentState); err != nil {
return errors.Wrap(err, "failed unmarshal the latest state")
}
entity.currentState = currentState

// set the event counter
entity.eventsCounter.Store(event.GetSequenceNumber())
Expand Down

0 comments on commit 5c5234f

Please sign in to comment.