quickjs-emscripten icon indicating copy to clipboard operation
quickjs-emscripten copied to clipboard

evalCode(type=module) throws instead of returning rejected promise

Open justjake opened this issue 1 year ago • 0 comments

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

justjake avatar Feb 26 '24 18:02 justjake