Skip to content

inspector: add --cond to node inspect probe mode#64328

Merged
nodejs-github-bot merged 2 commits into
nodejs:mainfrom
joyeecheung:probe-cond
Jul 13, 2026
Merged

inspector: add --cond to node inspect probe mode#64328
nodejs-github-bot merged 2 commits into
nodejs:mainfrom
joyeecheung:probe-cond

Conversation

@joyeecheung

Copy link
Copy Markdown
Member

On a hot path, the probe can record every hit and require filtering afterwards. This patch adds a per-probe --cond <expr> option that allows limiting the hit to only when the expression is truthy at the probe location. V8 evaluates it as the breakpoint's native condition, so the target is not paused when it does not hold, and a condition that throws is treated as false. Since in CDP, a location can only carry one breakpoint per URL pattern, probes sharing a location must share one condition (or none). Conflicting conditions are rejected.

Example:

// app.js
let total = 0;
for (let i = 0; i < 10; i++) {
  total += i;  // line 4
}
$ out/Release/node inspect --probe app.js:4 --expr 'total' \
                           --cond 'i % 3 === 0' app.js
Hit 1 at file:///path/to/app.js:3:3
  total = 0
Hit 2 at file:///path/to/app.js:3:3
  total = 3
Hit 3 at file:///path/to/app.js:3:3
  total = 15
Hit 4 at file:///path/to/app.js:3:3
  total = 36
Completed

Refs: #63646

@nodejs-github-bot nodejs-github-bot added debugger Issues and PRs related to the debugger subsystem. needs-ci PRs that need a full CI run. labels Jul 6, 2026
On a hot path, the probe can record every hit and require
filtering afterwards. This patch adds a per-probe `--cond <expr>`
option that allows limiting the hit to only when the expression
is truthy at the probe location. V8 evaluates it as the breakpoint's
native condition, so the target is not paused when it does not hold,
and a condition that throws is treated as false. Since in CDP,
a location can only carry one breakpoint per URL pattern,
probes sharing a location must share one condition (or none).
Conflicting conditions are rejected.

Example:

```js
// app.js
let total = 0;
for (let i = 0; i < 10; i++) {
  total += i;  // line 4
}
```

```
$ out/Release/node inspect --probe app.js:4 --expr 'total' \
                           --cond 'i % 3 === 0' app.js
```

```
Hit 1 at file:///path/to/app.js:3:3
  total = 0
Hit 2 at file:///path/to/app.js:3:3
  total = 3
Hit 3 at file:///path/to/app.js:3:3
  total = 15
Hit 4 at file:///path/to/app.js:3:3
  total = 36
Completed
```

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Comment thread lib/internal/debugger/inspect_probe.js
Comment thread doc/api/debugger.md Outdated
@joyeecheung

Copy link
Copy Markdown
Member Author

Thanks for the review, I think I've addressed the comments. @jasnell can you take another look? Thanks!

@joyeecheung joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 9, 2026
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 90.25%. Comparing base (e6a8d06) to head (2881e97).
⚠️ Report is 332 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #64328      +/-   ##
==========================================
- Coverage   92.01%   90.25%   -1.76%     
==========================================
  Files         379      741     +362     
  Lines      166972   241221   +74249     
  Branches    25554    45436   +19882     
==========================================
+ Hits       153639   217716   +64077     
- Misses      13041    15077    +2036     
- Partials      292     8428    +8136     
Files with missing lines Coverage Ξ”
lib/internal/debugger/inspect.js 94.00% <100.00%> (+1.40%) ⬆️
lib/internal/debugger/inspect_helpers.js 97.40% <100.00%> (+0.14%) ⬆️
lib/internal/debugger/inspect_probe.js 81.99% <100.00%> (+2.37%) ⬆️

... and 542 files with indirect coverage changes

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 9, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@joyeecheung joyeecheung added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Jul 13, 2026
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Jul 13, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/64328
βœ”  Done loading data for nodejs/node/pull/64328
----------------------------------- PR info ------------------------------------
Title      inspector: add --cond to node inspect probe mode (#64328)
Author     Joyee Cheung <joyeec9h3@gmail.com> (@joyeecheung)
Branch     joyeecheung:probe-cond -> nodejs:main
Labels     needs-ci, debugger, commit-queue-squash
Commits    2
 - inspector: add --cond to node inspect probe mode
 - fixup! inspector: add --cond to node inspect probe mode
Committers 1
 - Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64328
Refs: https://github.com/nodejs/node/issues/63646
Reviewed-By: James M Snell <jasnell@gmail.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/64328
Refs: https://github.com/nodejs/node/issues/63646
Reviewed-By: James M Snell <jasnell@gmail.com>
--------------------------------------------------------------------------------
   β„Ή  This PR was created on Mon, 06 Jul 2026 16:11:06 GMT
   βœ”  Approvals: 1
   βœ”  - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/64328#pullrequestreview-4655834114
   ✘  This PR needs to wait 2 more hours to land (or 0 minutes if there is one more approval)
   βœ”  Last GitHub CI successful
   β„Ή  Last Full PR CI on 2026-07-13T09:07:38Z: https://ci.nodejs.org/job/node-test-pull-request/74776/
- Querying data for job/node-test-pull-request/74776/
βœ”  Build data downloaded
   βœ”  Last Jenkins CI successful
--------------------------------------------------------------------------------
   βœ”  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/29260446092

@joyeecheung joyeecheung added commit-queue Add this label to land a pull request using GitHub Actions. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Jul 13, 2026
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 13, 2026
@nodejs-github-bot nodejs-github-bot merged commit 8c6cbb8 into nodejs:main Jul 13, 2026
83 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 8c6cbb8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. debugger Issues and PRs related to the debugger subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants