Commit 01e228d
fix: report eval scripts as
## 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>[eval] URL for inspector (#34192)1 parent 2270082 commit 01e228d
3 files changed
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
282 | 287 | | |
283 | 288 | | |
284 | 289 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3194 | 3194 | | |
3195 | 3195 | | |
3196 | 3196 | | |
3197 | | - | |
| 3197 | + | |
3198 | 3198 | | |
3199 | 3199 | | |
3200 | 3200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2280 | 2280 | | |
2281 | 2281 | | |
2282 | 2282 | | |
2283 | | - | |
| 2283 | + | |
2284 | 2284 | | |
2285 | 2285 | | |
2286 | 2286 | | |
| |||
0 commit comments