diff --git a/pkg/actor/mutation_registry.go b/pkg/actor/mutation_registry.go index 9fdfa88..37130bf 100644 --- a/pkg/actor/mutation_registry.go +++ b/pkg/actor/mutation_registry.go @@ -153,15 +153,14 @@ func (r *ProtoMutationRegistry) Apply(grain any, msg ...proto.Message) error { return fmt.Errorf("nil mutation message") } - rt := indirectType(reflect.TypeOf(msg)) - r.mutationRegistryMu.RLock() - entry, ok := r.mutationRegistry[rt] - r.mutationRegistryMu.RUnlock() - - if !ok { - return ErrMutationNotRegistered - } for _, m := range msg { + rt := indirectType(reflect.TypeOf(msg)) + r.mutationRegistryMu.RLock() + entry, ok := r.mutationRegistry[rt] + r.mutationRegistryMu.RUnlock() + if !ok { + return ErrMutationNotRegistered + } if err := entry.Handle(grain, m); err != nil { return err }