fix: fixed vm locking

This commit is contained in:
Simone Margaritelli 2021-04-04 15:58:48 +02:00
parent 3c20f2c9aa
commit 2b1ff7d59f
3 changed files with 35 additions and 31 deletions

View file

@ -56,9 +56,12 @@ func jsOnEventFunc(call otto.FunctionCall) otto.Value {
for event := range listener {
if expr == "" || event.Tag == expr {
// lock vm
I.script.Lock()
if _, err := cb.Call(otto.NullValue(), event); err != nil {
I.Events.Log(log.ERROR, "error dispatching event %s: %v", event.Tag, err)
}
I.script.Unlock()
}
}
}(filterExpr, cb)