fix: do not use goja.Value outside of run loop

This commit is contained in:
wpetit 2023-12-05 14:14:08 +01:00
parent 242bf379a8
commit b120e590b6
1 changed files with 4 additions and 4 deletions

View File

@ -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
})