mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 15:24:46 -05:00
fix: WebAssembly runtime error propagation (#6137)
Currently WebAssembly runtime errors don't propagate up to the user as they use urls to denote where the error occurred which get caught by the source-map pipeline which doesn't support the wasm scheme.
This commit is contained in:
parent
5ee2ce1b1c
commit
813210d433
4 changed files with 61 additions and 1 deletions
|
@ -50,7 +50,7 @@ impl DiskCache {
|
|||
out.push(scheme);
|
||||
|
||||
match scheme {
|
||||
"http" | "https" => {
|
||||
"http" | "https" | "wasm" => {
|
||||
let host = url.host_str().unwrap();
|
||||
let host_port = match url.port() {
|
||||
// Windows doesn't support ":" in filenames, so we represent port using a
|
||||
|
@ -196,6 +196,7 @@ mod tests {
|
|||
"https://deno.land/std/http/file_server.ts",
|
||||
"https/deno.land/std/http/file_server.ts",
|
||||
),
|
||||
("wasm://wasm/d1c677ea", "wasm/wasm/d1c677ea"),
|
||||
];
|
||||
|
||||
if cfg!(target_os = "windows") {
|
||||
|
|
|
@ -1872,6 +1872,12 @@ itest!(wasm_async {
|
|||
output: "wasm_async.out",
|
||||
});
|
||||
|
||||
itest!(wasm_unreachable {
|
||||
args: "run wasm_unreachable.js",
|
||||
output: "wasm_unreachable.out",
|
||||
exit_code: 1,
|
||||
});
|
||||
|
||||
itest!(top_level_await {
|
||||
args: "run --allow-read top_level_await.js",
|
||||
output: "top_level_await.out",
|
||||
|
|
50
cli/tests/wasm_unreachable.js
Normal file
50
cli/tests/wasm_unreachable.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
// 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 module = new WebAssembly.Module(binary);
|
||||
const instance = new WebAssembly.Instance(module);
|
||||
|
||||
instance.exports.unreachable();
|
3
cli/tests/wasm_unreachable.out
Normal file
3
cli/tests/wasm_unreachable.out
Normal file
|
@ -0,0 +1,3 @@
|
|||
error: Uncaught RuntimeError: unreachable
|
||||
at unreachable (<anonymous>:0:40)
|
||||
at [WILDCARD]/deno/cli/tests/wasm_unreachable.js:[WILDCARD]:18
|
Loading…
Reference in a new issue