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

[BUG]: WASM/Rust layer panics and cannot catch it. #4857

Open
nadr0 opened this issue Dec 23, 2024 · 2 comments
Open

[BUG]: WASM/Rust layer panics and cannot catch it. #4857

nadr0 opened this issue Dec 23, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@nadr0
Copy link
Collaborator

nadr0 commented Dec 23, 2024

Describe the bug

When you have a large import/export file the WASM runtime can panic due to some internal issue happening in rust. This will brick the TS workflow because the promise never returns and the logic of the system will not cleanup properly.

This prevents you from executing future KCL files so you cannot switch files or rerun your code.

Steps to Reproduce

Get the KCL files from here, it is two files one that is a massive export.

  1. Make a massive file to export
  2. Import it into a main.kcl file
  3. Wait for the WASM runtime to brick

Expected Behavior

We should be able to gracefully recover from a crashed WASM/Rust run of the AST.

this.isExecuting and some other cleanup calls need to be invoked to properly restore the TS state in the application after the promise for executeAST dies.

Screenshots and Recordings

Image

Desktop OS

Linux

Browser

No response

Version

v0.34.0

Additional Context

It has at least been a bug since v0.30.0

rustwasm/wasm-bindgen#2392

We will be using window.addEventListener('error', (event) => { ... }) to catch a global error since we cannot try catch the error from the executeAST promise it completely dies in that context.

We will need a global error handler that can map some of those runtime errors across the entire application state. It isn't amazing but after pairing with a few devs this is the only thing we could find. When rust panics we cannot catch that error in TS.

Sample error that is being caught with the global handler
Image

@nadr0 nadr0 added the bug Something isn't working label Dec 23, 2024
@jtran
Copy link
Collaborator

jtran commented Dec 23, 2024

I think an example of KCL triggering this is the same as in #4437, but if not, can you post it?

@nadr0
Copy link
Collaborator Author

nadr0 commented Dec 23, 2024

Yes it is the same one in that post above.

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

When branches are created from issues, their pull requests are automatically linked.

2 participants