Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Mar 10, 2024

Conversation

justjake
Copy link
Owner

@justjake justjake commented Feb 26, 2024

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 justjake merged commit f07790d into main Mar 10, 2024
1 check passed
@justjake justjake deleted the jake--missing-module-error branch March 10, 2024 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

evalCode won't return error in ES module mode
1 participant