deno
01e228d6 - fix: report eval scripts as `[eval]` URL for inspector (#34192)

Commit
157 days ago
fix: report eval scripts as `[eval]` URL for inspector (#34192) ## Summary Match Node.js by reporting `-e` and `deno eval` scripts as `[eval]` in inspector messages — `Debugger.scriptParsed`, `Debugger.paused` locations, and stack traces produced by `vm.runInThisContext`. Previously Deno reported the synthetic `file:///…/$deno$eval.mts` resource name (and `evalmachine.<anonymous>` for the user code inside the Node-compat wrapper), so any Node test that checks the script URL after attaching the inspector would fail. Two small changes: 1. **`eval_command`** appends `//# sourceURL=[eval]` to the eval source so V8 reports the eval main module URL as `[eval]`. Appended (not prepended) so user line numbers are preserved. 2. **`wrap_eval_code`** (used when Node-style `-e` is translated for child processes via `op_node_translate_cli_args`) passes `{ filename: "[eval]" }` to `vm.runInThisContext` so the wrapped user code is also reported with the `[eval]` URL. Enables `parallel/test-inspector-async-stack-traces-promise-then.js` in node compat. ## What's not in this PR The two timer tests referenced in the original issue (`test-inspector-async-stack-traces-set-interval.js` and `test-inspector-async-hook-setup-at-inspect-brk.js`) need pieces that don't exist yet and weren't appropriate to land here: - **`V8Inspector::asyncTaskScheduled` / `asyncTaskStarted` / `asyncTaskFinished` bindings.** Required so `setTimeout` / `setInterval` populate the `asyncStackTrace` field on `Debugger.paused`. V8 handles this automatically for promises via `SetAsyncEventDelegate`, but timers must call the hooks themselves. The `v8` crate doesn't expose these methods today — they need to be added in `denoland/rusty_v8` first. - **`node:internal/process/execution` frame on the async parent.** Both timer tests `.some()` over `asyncStackTrace.callFrames` looking for a frame with `frame.url === 'node:internal/process/execution'`. In Node this comes from `evalScript`, which lives in that internal module; Deno has no equivalent module today. - **`breakOnFirstLine` semantics.** `test-inspector-async-hook-setup-at-inspect-brk.js` expects the first `--inspect-brk` pause to be at line 1 of the user code, not at the wrapper's first statement. Node achieves this by passing `breakOnFirstLine` to `vm.Script::Compile`; V8 exposes the option but it's not on the Rust binding either. I left those tests commented out in `tests/node_compat/config.jsonc` for follow-up. ## Test plan - [x] `cargo test --test node_compat -- test-inspector-async-stack-traces-promise-then` → passes - [x] Confirm `[eval]` URL appears in `Debugger.scriptParsed` for both `deno eval` and spawn-translated `-e` paths - [x] `deno eval 'throw new Error()'` stack trace unchanged (V8 stack uses ScriptOrigin name, not sourceURL) - [x] `cargo test --test node_compat -- test-inspector-promises test-inspector-strip-types test-inspector-resource-name-to-url test-inspector-emit-protocol-event test-inspector-break-e test-inspector-multisession-ws` → no regression - [x] `cargo clippy --bin deno` Closes denoland/orchid#124 Co-authored-by: divybot <divybot@users.noreply.github.com> Co-authored-by: Divy Srivastava <me@littledivy.com>
Author
Parents
Loading