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

Exceptions thrown during module initialization are not caught #482

Closed
georgesmith46 opened this issue Jul 15, 2024 · 4 comments · Fixed by #490
Closed

Exceptions thrown during module initialization are not caught #482

georgesmith46 opened this issue Jul 15, 2024 · 4 comments · Fixed by #490
Labels
bug Something isn't working

Comments

@georgesmith46
Copy link
Contributor

Exceptions thrown during the initialization of a global or module are not caught. This means exceptions thrown at this point will be missing the exception message.

How to replicate

Running this

LLRT_NET_DENY=/ ./llrt -e 'console.log("123")'

Outputs

Error: Exception

But it should output

ReferenceError: LLRT_NET_DENY env contains an invalid URI

How to fix

This is where the exceptions should probably be caught:

init_global(&ctx)?;

Example of catching an exception:

if let Err(err) = f(&ctx).catch(&ctx) {

@richarddavison
Copy link
Contributor

That’s right, thanks for finding 👏

@richarddavison richarddavison added the bug Something isn't working label Jul 16, 2024
@nabetti1720
Copy link
Contributor

Whether or not an error occurs, it would be safer to take the same action below.

llrt/llrt_core/src/vm.rs

Lines 428 to 429 in 9e21153

timers::init_timers(&ctx)?;
init(&ctx, module_names)?;

@nabetti1720
Copy link
Contributor

nabetti1720 commented Jul 20, 2024

HI @richarddavison and @georgesmith46 , If there is no additional discussion, I would like to submit a PR to resolve this issue, if that is okay?
If you are already working on this issue, please let me know so I can work on another issue.

@georgesmith46
Copy link
Contributor Author

That's fine with me 👍

Let me know if you need a hand

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants