fix: do not use goja.Value outside of run loop
This commit is contained in:
parent
242bf379a8
commit
b120e590b6
|
@ -132,17 +132,17 @@ func (s *Server) Exec(ctx context.Context, callableOrFuncname any, args ...inter
|
||||||
value := result.value
|
value := result.value
|
||||||
|
|
||||||
if promise, ok := IsPromise(value); ok {
|
if promise, ok := IsPromise(value); ok {
|
||||||
value = s.waitForPromise(promise)
|
return s.waitForPromise(promise), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return value.Export(), nil
|
return value.Export(), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) waitForPromise(promise *goja.Promise) goja.Value {
|
func (s *Server) waitForPromise(promise *goja.Promise) any {
|
||||||
var (
|
var (
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
value goja.Value
|
value any
|
||||||
)
|
)
|
||||||
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
@ -162,7 +162,7 @@ func (s *Server) waitForPromise(promise *goja.Promise) goja.Value {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
value = promise.Result()
|
value = promise.Result().Export()
|
||||||
|
|
||||||
breakLoop = true
|
breakLoop = true
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue