diff options
author | Andreu Botella <abb@randomunok.com> | 2021-10-10 07:03:23 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-10 16:03:23 +0200 |
commit | 5edd2771619ddc3cd2f6c76cc93ee64277aa17c2 (patch) | |
tree | 88307d65fc81388579328dfb7d3da782ffa3f5a9 /cli/tests | |
parent | 6ac0337165d5e341eee9bff9ff0065894289df69 (diff) |
feat: Show the URL of streaming WASM modules in stack traces (#12268)
WebAssembly modules compiled through `WebAssembly.compile()` and similar
non-streaming APIs don't have a URL associated to them, because they
have been compiled from a buffer source. In stack traces, V8 will use
a URL such as `wasm://wasm/d1c677ea`, with a hash of the module.
However, wasm modules compiled through streaming APIs, like
`WebAssembly.compileStreaming()`, do have a known URL, which can be
obtained from the `Response` object passed into the streaming APIs. And
as per the developer-facing display conventions in the WebAssembly
Web API spec, this URL should be used in stack traces. This change
implements that.
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration/run_tests.rs | 9 | ||||
-rw-r--r-- | cli/tests/testdata/unreachable.wasm | bin | 0 -> 42 bytes | |||
-rw-r--r-- | cli/tests/testdata/wasm_unreachable.js | 47 | ||||
-rw-r--r-- | cli/tests/testdata/wasm_unreachable.out | 4 | ||||
-rw-r--r-- | cli/tests/testdata/wasm_url.js | 8 | ||||
-rw-r--r-- | cli/tests/testdata/wasm_url.out | 3 |
6 files changed, 24 insertions, 47 deletions
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index 8c337b771..f247aa93f 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -856,11 +856,18 @@ itest!(wasm_async { }); itest!(wasm_unreachable { - args: "run wasm_unreachable.js", + args: "run --allow-read wasm_unreachable.js", output: "wasm_unreachable.out", exit_code: 1, }); +itest!(wasm_url { + args: "run --quiet --allow-net=localhost:4545 wasm_url.js", + output: "wasm_url.out", + exit_code: 1, + http_server: true, +}); + itest!(weakref { args: "run --quiet --reload weakref.ts", output: "weakref.ts.out", diff --git a/cli/tests/testdata/unreachable.wasm b/cli/tests/testdata/unreachable.wasm Binary files differnew file mode 100644 index 000000000..a4110ee39 --- /dev/null +++ b/cli/tests/testdata/unreachable.wasm diff --git a/cli/tests/testdata/wasm_unreachable.js b/cli/tests/testdata/wasm_unreachable.js index 991ebcec8..36aab0d84 100644 --- a/cli/tests/testdata/wasm_unreachable.js +++ b/cli/tests/testdata/wasm_unreachable.js @@ -1,50 +1,9 @@ // WebAssembly module containing a single function with an unreachable instruction -const binary = Uint8Array.from([ - 0x00, - 0x61, - 0x73, - 0x6d, - 0x01, - 0x00, - 0x00, - 0x00, - 0x01, - 0x04, - 0x01, - 0x60, - 0x00, - 0x00, - 0x03, - 0x02, - 0x01, - 0x00, - 0x07, - 0x0f, - 0x01, - 0x0b, - 0x75, - 0x6e, - 0x72, - 0x65, - 0x61, - 0x63, - 0x68, - 0x61, - 0x62, - 0x6c, - 0x65, - 0x00, - 0x00, - 0x0a, - 0x05, - 0x01, - 0x03, - 0x00, - 0x00, - 0x0b, -]); +const binary = await Deno.readFile("./unreachable.wasm"); const module = new WebAssembly.Module(binary); const instance = new WebAssembly.Instance(module); +// Compare the stack trace with wasm_url.js, which compiles the WASM module with +// streaming APIs. instance.exports.unreachable(); diff --git a/cli/tests/testdata/wasm_unreachable.out b/cli/tests/testdata/wasm_unreachable.out index 28fe00de6..cbb6b6519 100644 --- a/cli/tests/testdata/wasm_unreachable.out +++ b/cli/tests/testdata/wasm_unreachable.out @@ -1,3 +1,3 @@ -error: Uncaught RuntimeError: unreachable - at <anonymous> (wasm://wasm/[WILDCARD]) +error: Uncaught (in promise) RuntimeError: unreachable + at <anonymous> (wasm://wasm/d1c677ea:1:41) at [WILDCARD]/wasm_unreachable.js:[WILDCARD] diff --git a/cli/tests/testdata/wasm_url.js b/cli/tests/testdata/wasm_url.js new file mode 100644 index 000000000..bb7ccd73d --- /dev/null +++ b/cli/tests/testdata/wasm_url.js @@ -0,0 +1,8 @@ +const module = await WebAssembly.compileStreaming( + fetch("http://localhost:4545/unreachable.wasm"), +); +const instance = new WebAssembly.Instance(module); + +// Compare the stack trace with wasm_unreachable.js, which compiles the WASM +// module with synchronous APIs. +instance.exports.unreachable(); diff --git a/cli/tests/testdata/wasm_url.out b/cli/tests/testdata/wasm_url.out new file mode 100644 index 000000000..c88b51020 --- /dev/null +++ b/cli/tests/testdata/wasm_url.out @@ -0,0 +1,3 @@ +error: Uncaught (in promise) RuntimeError: unreachable + at <anonymous> (http://localhost:4545/unreachable.wasm:1:41) + at [WILDCARD]/wasm_url.js:[WILDCARD] |