fix(cli): report eval scripts as [eval] URL for inspector#34192
Merged
Conversation
Match Node.js by reporting `-e` and `deno eval` scripts as `[eval]` in
inspector messages (Debugger.scriptParsed, Debugger.paused locations,
stack traces produced by `vm.runInThisContext`).
This unblocks `parallel/test-inspector-async-stack-traces-promise-then.js`
in node compat, which checks the script URL via `Debugger.paused`.
Two changes:
1. `eval_command` appends `//# sourceURL=[eval]` to the eval source so V8
reports the eval main module URL as `[eval]` (it falls back to the
`$deno$eval.mts` resource name otherwise). 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.
The remaining two failing tests
(`test-inspector-async-stack-traces-set-interval.js` and
`test-inspector-async-hook-setup-at-inspect-brk.js`) need additional
infrastructure that isn't covered here: V8 inspector
`asyncTaskScheduled` / `asyncTaskStarted` / `asyncTaskFinished` bindings
(not exposed by the `v8` crate today) wired through Deno's timer
plumbing, a `node:internal/process/execution` URL on the wrapper's
frames, and `breakOnFirstLine` semantics so `--inspect-brk` pauses
inside the user code rather than at the wrapper.
Closes denoland/orchid#124
Co-Authored-By: Divy Srivastava <me@littledivy.com>
littledivy
approved these changes
May 17, 2026
bartlomieju
added a commit
that referenced
this pull request
May 17, 2026
Already passing after #34192.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Match Node.js by reporting
-eanddeno evalscripts as[eval]in inspector messages —Debugger.scriptParsed,Debugger.pausedlocations, and stack traces produced byvm.runInThisContext. Previously Deno reported the syntheticfile:///…/$deno$eval.mtsresource name (andevalmachine.<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:
eval_commandappends//# 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.wrap_eval_code(used when Node-style-eis translated for child processes viaop_node_translate_cli_args) passes{ filename: "[eval]" }tovm.runInThisContextso the wrapped user code is also reported with the[eval]URL.Enables
parallel/test-inspector-async-stack-traces-promise-then.jsin node compat.What's not in this PR
The two timer tests referenced in the original issue
(
test-inspector-async-stack-traces-set-interval.jsandtest-inspector-async-hook-setup-at-inspect-brk.js) need pieces thatdon't exist yet and weren't appropriate to land here:
V8Inspector::asyncTaskScheduled/asyncTaskStarted/asyncTaskFinishedbindings. Required sosetTimeout/setIntervalpopulate theasyncStackTracefield onDebugger.paused. V8 handles this automatically for promises viaSetAsyncEventDelegate, but timers must call the hooks themselves. Thev8crate doesn't expose these methods today — they need to be added indenoland/rusty_v8first.node:internal/process/executionframe on the async parent. Both timer tests.some()overasyncStackTrace.callFrameslooking for a frame withframe.url === 'node:internal/process/execution'. In Node this comes fromevalScript, which lives in that internal module; Deno has no equivalent module today.breakOnFirstLinesemantics.test-inspector-async-hook-setup-at-inspect-brk.jsexpects the first--inspect-brkpause to be at line 1 of the user code, not at the wrapper's first statement. Node achieves this by passingbreakOnFirstLinetovm.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.jsoncfor follow-up.Test plan
cargo test --test node_compat -- test-inspector-async-stack-traces-promise-then→ passes[eval]URL appears inDebugger.scriptParsedfor bothdeno evaland spawn-translated-epathsdeno eval 'throw new Error()'stack trace unchanged (V8 stack uses ScriptOrigin name, not sourceURL)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 regressioncargo clippy --bin denoCloses denoland/orchid#124