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
|
||||
|
||||
if promise, ok := IsPromise(value); ok {
|
||||
value = s.waitForPromise(promise)
|
||||
return s.waitForPromise(promise), nil
|
||||
}
|
||||
|
||||
return value.Export(), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) waitForPromise(promise *goja.Promise) goja.Value {
|
||||
func (s *Server) waitForPromise(promise *goja.Promise) any {
|
||||
var (
|
||||
wg sync.WaitGroup
|
||||
value goja.Value
|
||||
value any
|
||||
)
|
||||
|
||||
wg.Add(1)
|
||||
@ -162,7 +162,7 @@ func (s *Server) waitForPromise(promise *goja.Promise) goja.Value {
|
||||
return
|
||||
}
|
||||
|
||||
value = promise.Result()
|
||||
value = promise.Result().Export()
|
||||
|
||||
breakLoop = true
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user