Skip to content

Commit c86d77c

Browse files
committed
fix: Initiate state before recovering from snapshot
1 parent 2565190 commit c86d77c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: actor.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,11 @@ func (entity *actor[T]) recoverFromSnapshot(ctx context.Context) error {
152152
// we do have the latest state just recover from it
153153
if event != nil {
154154
// set the current state
155-
if err := event.GetResultingState().UnmarshalTo(entity.currentState); err != nil {
155+
currentState := entity.InitialState()
156+
if err := event.GetResultingState().UnmarshalTo(currentState); err != nil {
156157
return errors.Wrap(err, "failed unmarshal the latest state")
157158
}
159+
entity.currentState = currentState
158160

159161
// set the event counter
160162
entity.eventsCounter.Store(event.GetSequenceNumber())

0 commit comments

Comments
 (0)