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

Log stacks of imported JS functions that throw but aren't marked catch #1466

Merged
merged 1 commit into from
May 1, 2019

Conversation

fitzgen
Copy link
Member

@fitzgen fitzgen commented Apr 16, 2019

Particularly useful in our tests, where we don't have the regular console logging with post-facto object inspection, and instead need to provide all this info up front.

@fitzgen fitzgen requested a review from alexcrichton April 16, 2019 18:51
@fitzgen
Copy link
Member Author

fitzgen commented Apr 16, 2019

I haven't actually tested this yet, so lets see what CI says...

@alexcrichton
Copy link
Contributor

Looks like an example from CI is:

wasm-bindgen: imported JS function that was not marked as `catch` threw an error: Error: expected value of type CustomType
    at module.exports.__wbg_customtypereturn2_1286271038d507a7 (/home/vsts/work/1/s/target/wasm32-unknown-unknown/wbg-tmp/wasm-bindgen-test.js:3367:19)
    at wasm::imports::custom_type_return_2::hb6ffbd5d220e0217 (wasm-function[4363]:34)
    at wasm::imports::interpret_2_as_custom_type::hb77af1ae697ac8fe (wasm-function[9291]:1)
    at interpret_2_as_custom_type (wasm-function[5169]:34)
    at module.exports.interpret_2_as_custom_type (/home/vsts/work/1/s/target/wasm32-unknown-unknown/wbg-tmp/wasm-bindgen-test.js:3489:17)
    at getActual (assert.js:578:5)
    at Function.throws (assert.js:690:24)
    at exports.interpret_2_as_custom_type (/home/vsts/work/1/s/tests/wasm/imports.js:93:10)
    at module.exports.__wbg_interpret2ascustomtype_d9d0ff1b5ecdd26a (/home/vsts/work/1/s/target/wasm32-unknown-unknown/wbg-tmp/wasm-bindgen-test.js:3381:9)
    at wasm::imports::js_interpret_2_as_custom_type::hed38e64eaec78046 (wasm-function[7746]:34) 
Stack:
 Error: expected value of type CustomType
    at module.exports.__wbg_customtypereturn2_1286271038d507a7 (/home/vsts/work/1/s/target/wasm32-unknown-unknown/wbg-tmp/wasm-bindgen-test.js:3367:19)
    at wasm::imports::custom_type_return_2::hb6ffbd5d220e0217 (wasm-function[4363]:34)
    at wasm::imports::interpret_2_as_custom_type::hb77af1ae697ac8fe (wasm-function[9291]:1)
    at interpret_2_as_custom_type (wasm-function[5169]:34)
    at module.exports.interpret_2_as_custom_type (/home/vsts/work/1/s/target/wasm32-unknown-unknown/wbg-tmp/wasm-bindgen-test.js:3489:17)
    at getActual (assert.js:578:5)
    at Function.throws (assert.js:690:24)
    at exports.interpret_2_as_custom_type (/home/vsts/work/1/s/tests/wasm/imports.js:93:10)
    at module.exports.__wbg_interpret2ascustomtype_d9d0ff1b5ecdd26a (/home/vsts/work/1/s/target/wasm32-unknown-unknown/wbg-tmp/wasm-bindgen-test.js:3381:9)
    at wasm::imports::js_interpret_2_as_custom_type::hed38e64eaec78046 (wasm-function[7746]:34)

aren't those two stack traces the same though? I think the first is from logging the error object e and the second is the .stack value. Although logging e as a value is probably Node-specific, so maybe it's only redundant in node and not in browsers?

@fitzgen
Copy link
Member Author

fitzgen commented Apr 17, 2019

Fixed it up so it should be more robust now and also logs the import function name:

wasm-bindgen: imported JS function `__wbg_exceptionsthrow_56dec8de1c61ee90` that was not marked as `catch` threw an error: error!

            Stack:
            Error: error!
    at exports.exceptions_throw (/home/fitzgen/wasm-bindgen/tests/wasm/imports.js:52:9)
    at module.exports.__wbg_exceptionsthrow_56dec8de1c61ee90 (/home/fitzgen/wasm-bindgen/target/wasm32-unknown-unknown/wbg-tmp/wasm-bindgen-test.js:5464:9)
    at wasm::imports::exceptions_throw::hd525a420fd4ef0c2 (wasm-function[7740]:34)
    at wasm::imports::exceptions_propagate::h8b6b8f1560e6f648 (wasm-function[9304]:1)
    at exceptions_propagate (wasm-function[5177]:34)
    at module.exports.exceptions_propagate (/home/fitzgen/wasm-bindgen/target/wasm32-unknown-unknown/wbg-tmp/wasm-bindgen-test.js:5829:17)
    at getActual (assert.js:576:5)
    at Function.throws (assert.js:688:24)
    at exports.test_exception_propagates (/home/fitzgen/wasm-bindgen/tests/wasm/imports.js:58:10)
    at module.exports.__wbg_testexceptionpropagates_a49dd56847eedd4d (/home/fitzgen/wasm-bindgen/target/wasm32-unknown-unknown/wbg-tmp/wasm-bindgen-test.js:5493:9)

@alexcrichton
Copy link
Contributor

Hm I'm not entirely sure why CI failed, want to repush and see if it retriggers?

…tch`

Particularly useful in our tests, where we don't have the regular console
logging with post-facto object inspection, and instead need to provide all this
info up front.
@alexcrichton alexcrichton merged commit 358ee18 into rustwasm:master May 1, 2019
@alexcrichton
Copy link
Contributor

Oops forgot to merge this once it went green!

@fitzgen fitzgen deleted the log-stacks branch May 1, 2019 22:06
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