diff --git a/js/common/frozen_object.go b/js/common/frozen_object.go index 6ee0c9e4148..ee36ef74217 100644 --- a/js/common/frozen_object.go +++ b/js/common/frozen_object.go @@ -50,16 +50,18 @@ func (f *freezing) deepFreeze(val goja.Value) error { for _, key := range o.Keys() { prop := o.Get(key) - if prop != nil { - frozen, err := f.isFrozen(goja.Undefined(), prop) - if err != nil { - return err - } - if !frozen.ToBoolean() { // prevent cycles - if err = f.deepFreeze(prop); err != nil { - return fmt.Errorf("deep freezing the property %s failed: %w", key, err) - } - } + if prop == nil { + continue + } + frozen, err := f.isFrozen(goja.Undefined(), prop) + if err != nil { + return err + } + if frozen.ToBoolean() { // prevent cycles + continue + } + if err = f.deepFreeze(prop); err != nil { + return fmt.Errorf("deep freezing the property %s failed: %w", key, err) } }