vscode_deno
vscode_deno copied to clipboard
debug wasm: Uncaught TypeError: WebAssembly.compile(): Argument 0 must be a buffer source
Describe the bug Debug wasm within Vscode will throw this error:
Debugger session started.
Debugger session ended
error: Uncaught TypeError: WebAssembly.compile(): Argument 0 must be a buffer source
When I debug it within chrome, it works well:
$ deno run -A --inspect --inspect-brk demo.ts
So, I guess that the deno plugin for vscode may have a bug.
To Reproduce Here is a bad case example : https://github.com/ahuigo/deno-debug-example.
- first step: config vscode's .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"request": "launch",
"name": "debug wasm",
"type": "pwa-node",
"program": "${workspaceFolder}/demo.ts",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"args": ["--dev"],
"runtimeArgs": [
"run",
"--inspect",
"--inspect-brk",
"-A"
],
"smartStep": false,
"attachSimplePort": 9229
}
]
}
- second step: write demo.ts
const imports= { imports: { imported_func: (arg) => console.log(arg) } };
const wasmCode = new Uint8Array([
0, 97, 115, 109, 1, 0, 0, 0, 1, 133, 128, 128, 128, 0, 1, 96, 0, 1, 127,
3, 130, 128, 128, 128, 0, 1, 0, 4, 132, 128, 128, 128, 0, 1, 112, 0, 0,
5, 131, 128, 128, 128, 0, 1, 0, 1, 6, 129, 128, 128, 128, 0, 0, 7, 145,
128, 128, 128, 0, 2, 6, 109, 101, 109, 111, 114, 121, 2, 0, 4, 109, 97,
105, 110, 0, 0, 10, 138, 128, 128, 128, 0, 1, 132, 128, 128, 128, 0, 0,
65, 42, 11
]);
const res=new Response(wasmCode, {headers: [["Content-Type", "application/wasm"]]})
const r = await WebAssembly.instantiateStreaming(res,imports)
console.log(r)
- Start debugging with F5
deno run --inspect --inspect-brk -A ./demo.ts --dev
Debugger listening on ws://127.0.0.1:9229/ws/153d75ee-906d-465c-b05e-d9d48dca5437
Visit chrome://inspect to connect to the debugger.
Deno is waiting for debugger to connect.
Debugger session started.
Debugger session ended
error: Uncaught TypeError: WebAssembly.compile(): Argument 0 must be a buffer source
Expected behavior Not throw any error. (When I debug it within chrome, it works well)
Versions I tried both deno 1.23.1 and deno 1.24.3, same error:
....
Debugger session started.
Debugger session ended
error: Uncaught TypeError: WebAssembly.compile(): Argument 0 must be a buffer source
My environment
macOsx: 12.3.1
cpu: Darwin 21.4.0 arm64 core(10) Apple M1 Pro
vscode: 1.68.1 30d9c6cd9483b2cc586687151bcbcd635f373630 arm64
deno 1.24.3 (release, aarch64-apple-darwin)
v8 10.4.132.20
typescript 4.7.4
deno extensions:
[email protected]
[email protected]
+1 on this issue
$ deno --version
deno 1.30.1 (release, x86_64-pc-windows-msvc)
v8 10.9.194.5
typescript 4.9.4
Extension version: v3.17.0
Same setup and error, same observations where debugging works in chrome but fails in vscode
The same happen (in nvim) with another implementation https://github.com/mfussenegger/nvim-dap
Maybe the issue lies in https://github.com/microsoft/vscode-js-debug
Hey folks, sorry for a slow response. Do you still experience the same issue with latest Deno?
The same reproduction steps still produce the same error deno 1.35.1
Same error with with deno 1.33.4, here is an example: https://github.com/ahuigo/deno-debug-example.
Bad case reproduce step:
- Install vscode and vscode-deno plugin.
- Open this project with vscode
- Press
F5
, then there will be an error likeerror: Uncaught TypeError: WebAssembly.compile(): Argument 0 must be a buffer source
This is tested by:
kernel: 21.6.0
os: macOSX 12.6
cpu: Darwin 21.6.0 arm64 core(10) Apple M1 Pro
vscode: 1.76.2
deno 1.33.4
v8 11.4.183.2
typescript 5.0.4
deno extensions: [email protected]
+1 for this on Deno 1.37.1 with the same steps to reproduce as people above.
I can easily reproduce this with the deno_graph
project. When I open up https://github.com/denoland/deno_graph/blob/main/js/test.ts in vs code and click "run" on the first test I get:
running 1 test from ./js/test.ts
createGraph() ... ok (101ms)
ok | 1 passed | 0 failed | 21 filtered out (107ms)
But when I click "debug" I get:
running 1 test from ./js/test.ts
createGraph() ... FAILED (15ms)
ERRORS
createGraph() => ./js/test.ts:19:6
error: TypeError: WebAssembly.compile(): Argument 0 must be a buffer source
at eventLoopTick (ext:core/01_core.js:182:7)
FAILURES
createGraph() => ./js/test.ts:19:6
FAILED | 0 passed | 1 failed | 21 filtered out (21ms)
This is annoying because I'm trying to use createGraph
in fresh, but whenever I try to step past this call, the debugger fails.
I am getting the same error trying to use:
export { transpile } from "https://deno.land/x/[email protected]/mod.ts";
Deno 1.40.5 Deno extension v3.33.3
I thought i'd throw a work around out there while this awaits resolution. If possible, wrap the call throwing this error in its own Worker, this throws the WebAssembly out on a separate thread, and make the rest of the app debug-able.