Skip to content

debugger: list and clear breakpoints set on functions - #66744

Open
dualfroz wants to merge 2 commits into
nodejs:mainfrom
dualfroz:fix/41790-function-breakpoints
Open

dualfroz wants to merge 2 commits into
nodejs:mainfrom
dualfroz:fix/41790-function-breakpoints

Conversation

@dualfroz

Copy link
Copy Markdown
Contributor

Fixes: #41790

picks up #53798 by @rotu (kept as co-author). sb('fn()') went
through debug() from the command line API, so there was no
breakpoint id to keep. it now uses Debugger.setBreakpointOnFunctionCall,
the breakpoint shows up in breakpoints as fn() and cb('fn()')
removes it. like before, these aren't restored after restart.
test-debugger-break needed a small update since the function
breakpoint is now listed and the pause reads break in.

`sb('fn()')` used the `debug()` command line API, which gives no
breakpoint id, so these breakpoints never showed up in `breakpoints`
and could not be removed with `cb`. Use
`Debugger.setBreakpointOnFunctionCall` instead and keep the breakpoint
in the list, so it is listed as `fn()` and can be cleared with
`cb('fn()')`.

Fixes: nodejs#41790
Co-authored-by: Dan Rose <danoftheroses@gmail.com>
Signed-off-by: dualfroz <me@dualfroz.com>
@nodejs-github-bot nodejs-github-bot added debugger Issues and PRs related to the Node.js command-line debugger. needs-ci PRs that need a full CI run. labels Oct 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Welcome to Node.js, and thank you for your first contribution!

Before review, please take a moment to read:

Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal.

@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.86207% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.55%. Comparing base (782a3ac) to head (b31508c).
⚠️ Report is 676 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/debugger/inspect_repl.js 75.86% 6 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66744      +/-   ##
==========================================
+ Coverage   90.47%   90.55%   +0.07%     
==========================================
  Files         791      801      +10     
  Lines      277225   284228    +7003     
  Branches    53313    54911    +1598     
==========================================
+ Hits       250829   257380    +6551     
- Misses      16801    17003     +202     
- Partials     9595     9845     +250     
Files with missing lines Coverage Δ
lib/internal/debugger/inspect_repl.js 92.06% <75.86%> (+0.71%) ⬆️

... and 305 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.

@inoway46 inoway46 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I previously spent some time looking into the debugger code and noticed a couple of things while reviewing this change. I've left two inline suggestions about object handle cleanup and evaluation error handling.

Comment thread lib/internal/debugger/inspect_repl.js Outdated
});
return PromisePrototypeThen(debugCall, ({ result, wasThrown }) => {
Runtime.evaluate({ expression: functionName });
return PromisePrototypeThen(evaluation, ({ result, wasThrown }) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we release result.objectId once we're done processing the evaluation result, including error paths?

The handle remains valid after Debugger.removeBreakpoint, retaining the function and potentially its captured state. Releasing it after setting the breakpoint still allows the breakpoint to fire.

Evaluation errors and non-function results can also include an objectId, so those paths should release the handle too.

Comment thread lib/internal/debugger/inspect_repl.js Outdated
return PromisePrototypeThen(debugCall, ({ result, wasThrown }) => {
Runtime.evaluate({ expression: functionName });
return PromisePrototypeThen(evaluation, ({ result, wasThrown }) => {
if (wasThrown) return convertResultToError(result);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we check exceptionDetails instead of wasThrown before checking result.type? Both evaluation methods report exceptions through exceptionDetails.

The wasThrown check predates this PR, but the new type check turns evaluation errors into “not a function” errors. In the new sb('x()') test, x is still uninitialized, so evaluating it throws a ReferenceError.

Could we use sb('10()') for the non-function case and test evaluation errors separately?

@dualfroz

Copy link
Copy Markdown
Contributor Author

applied both, thanks. it checks exceptionDetails now and releases the handle on every path

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

Labels

debugger Issues and PRs related to the Node.js command-line debugger. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"breakpoints" command not listing breakpoints: "No breakpoints yet"

3 participants