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

Fix regression with loadJS always throwing #217

Merged
merged 1 commit into from
Aug 18, 2021
Merged

Conversation

calebeby
Copy link
Member

@calebeby calebeby commented Aug 18, 2021

This is what happens when I don't write a test for the core functionality and use test.todo 😬 🙈

Regression introduced in #199

@@ -383,6 +383,7 @@ const createTab = async ({
const res = await safeEvaluate(
loadJS,
`import(${JSON.stringify(url)})
.then(mod => {})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is why this works:

On line 396, that function checks res to see if it exists, it assumes that it is an error (that is how it works with runJS). If res exists, then it throws it.

In the case of loadJS, res is the module object that got imported. So I was seeing a confusing error that said Thrown: {}. The addition of this line fixes this bug because it discards the imported module so res is undefined. The catch block still works to make res exist if something was thrown.

Copy link
Member

@gerardo-rodriguez gerardo-rodriguez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation, @calebeby! 👍

@calebeby calebeby merged commit 93058ed into main Aug 18, 2021
@calebeby calebeby deleted the loadjs-regression branch August 18, 2021 19:29
@github-actions github-actions bot mentioned this pull request Aug 18, 2021
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.

2 participants