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

In debug mode, always catch imported JS function's exceptions and log if they throw #1176

Closed
fitzgen opened this issue Jan 14, 2019 · 0 comments

Comments

@fitzgen
Copy link
Member

fitzgen commented Jan 14, 2019

When we are in debug mode, this

#[wasm_bindgen]
extern {
    fn foo() -> u32;
}

should emit JS glue code something like this:

const __wbg_import_function_foo_target = foo;
export __wbg_import_function_foo = function () {
    try {
        return foo();
    } catch (e) {
        console.error("wasm-bindgen: imported JS function that was not marked as `catch` threw an error:", e);
        throw e;
    }
};

This will help us debug when imported JS functions throw and we don't catch the errors.

alexcrichton added a commit to alexcrichton/wasm-bindgen that referenced this issue Jan 15, 2019
This commit updates the `--debug` output of `wasm-bindgen` from the CLI
to catch all JS exceptions from imported functions, log such, and then
rethrow. It's hoped that this can be used when necessary to learn more
information about thrown exceptions and where an uncaught exception
could be causing issues with Rust code.

Closes rustwasm#1176
s9ferech added a commit to s9ferech/enso-ide that referenced this issue Nov 16, 2020
Passing them on from an imported JavaScript function does not seem to be supported by wasm-bindgen:
rustwasm/wasm-bindgen#1176
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant