quickjs-emscripten
quickjs-emscripten copied to clipboard
evalCode(type=module) throws instead of returning rejected promise
trafficstars
Fixes #160
New versions of quickjs library return Promise<void> when evaluating a module.
Our wrapper code unwrapped this implicit promise if it's resolved and return the module exports, and replace a pending promise with pending Promise<ModuleExports>.
However, our code passed through the rejected promise value as a success result back to the caller, who probably isn't expecting a promise.
With this PR, we consider the sync rejected module evaluation promise as an error, restoring the behavior of errors thrown during evaluation.
Also: context.dump(val) now inspects promises