node icon indicating copy to clipboard operation
node copied to clipboard

inspector: introduce the `--inspect-wait` flag

Open cola119 opened this issue 9 months ago • 13 comments

This PR introduces the --inspect-wait flag, which allows debugger to wait for attachement. This flag is useful when you want to debug the code from the beginning. Unlike --inspect-brk, which breaks on the first line, this flag waits for debugger to be connected and then runs the code as soon as a session is established.

It's designed to simplify debugging by removing the need for manual intervention and providing a smoother debugging experience. With support for breaking on the first line and automatic process resumption, it streamlines the debugging process.

Other runtime works include:

  • Deno https://docs.deno.com/runtime/manual/references/vscode_deno/#using-the-debugger
  • Bun https://bun.sh/docs/runtime/debugger#inspect-wait

cola119 avatar Apr 28 '24 13:04 cola119

I'm not sure I understand the use case? Shouldn't this be solved from the consumer side that can call Debugger.resume (or some such) after attaching with --inspect-brk?

benjamingr avatar Apr 28 '24 14:04 benjamingr

Shouldn't this be solved from the consumer side that can call Debugger.resume (or some such) after attaching with --inspect-brk?

Yes, the --inspect-wait flag acts like a combination of --inspect-brk and the client's Debugger.resume call. It's designed to simplify debugging by removing the need for manual intervention and providing a smoother debugging experience. With support for breaking on the first line and automatic process resumption, I believe it streamlines the debugging process.

cola119 avatar Apr 29 '24 02:04 cola119

cc @nodejs/inspector

cola119 avatar Apr 30 '24 05:04 cola119

Please update https://github.com/nodejs/node/blob/main/doc/node.1 also.

daeyeon avatar May 01 '24 07:05 daeyeon

@daeyeon Done

cola119 avatar May 01 '24 10:05 cola119

Failed to start CI
   ⚠  No approving reviews found
   ✘  Refusing to run CI on potentially unsafe PR
https://github.com/nodejs/node/actions/runs/8908137018

github-actions[bot] avatar May 01 '24 10:05 github-actions[bot]

CI: https://ci.nodejs.org/job/node-test-pull-request/58884/

nodejs-github-bot avatar May 03 '24 04:05 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/58887/

nodejs-github-bot avatar May 03 '24 08:05 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/58922/

nodejs-github-bot avatar May 04 '24 12:05 nodejs-github-bot

@jasnell @daeyeon I've updated the Node.js debugger documentation to clarify the difference between the three flags. Please review it again and let me know if you have any better ideas. ba10f452ee96756b19000d847d6214603ae460ba

cola119 avatar May 05 '24 13:05 cola119

Failed to start CI
   ⚠  Something was pushed to the Pull Request branch since the last approving review.
   ✘  Refusing to run CI on potentially unsafe PR
https://github.com/nodejs/node/actions/runs/8967104489

github-actions[bot] avatar May 06 '24 09:05 github-actions[bot]

CI: https://ci.nodejs.org/job/node-test-pull-request/59034/

nodejs-github-bot avatar May 08 '24 12:05 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/59071/

nodejs-github-bot avatar May 10 '24 03:05 nodejs-github-bot

Landed in c0ae3b237364f5e6723cfa70784eafd55f466a7e

nodejs-github-bot avatar May 11 '24 18:05 nodejs-github-bot

This PR adds a feature so it should be labeled https://github.com/nodejs/node/labels/semver-minor (this is not supposed to be done by releasers).

targos avatar May 13 '24 12:05 targos

@targos Understood, I'll keep that in mind.

cola119 avatar May 13 '24 13:05 cola119

I'm not sure I understand the use case? Shouldn't this be solved from the consumer side that can call Debugger.resume (or some such) after attaching with --inspect-brk?

NiM has had this feature since circa 2020 https://github.com/nodejs/node/issues/30911#issuecomment-602140349 so I find this amusing.

june07 avatar Aug 11 '24 07:08 june07