-
Notifications
You must be signed in to change notification settings - Fork 31.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
src: check if the script file exists before starting inspector #42673
base: main
Are you sure you want to change the base?
Conversation
Review requested:
|
c00fcdc
to
e735cf1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agent::PauseOnNextJavascriptStatement
assumes that the inspector agent is started with Agent::Start
and Agent::client_
exists. Early break from Environment::InitializeInspector
and not calling Agent::Start
can break the assumption that if the process is started with --inspect-brk
the agent must have been started.
Like say, we can crash the process with segment fault with the following setup:
// preload.js
require('fs').writeFileSync('./main.js', 'console.log("main")', 'utf8);
and run node with node --inspect-brk --require=./preload.js main.js
with main.js not existing.
Maybe we can instead delay the wait for client connection to the time before we pause on next javascript statement?
match = true; | ||
break; | ||
} | ||
if (/Debugger listening on/.test(stderr)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: can we assert that this statement is not present in the output?
Fixed #42600
Currently
node --inspect-brk index.js
will start the inspector and wait a connection event thoughindex.js
doesn't exist. And immediately after connected, node will throwCannot find module
error and wait to be disconnected.This PR added the ability to check for the existence of the script file before an inspector agent is started. If the script is missing, inspector is not enabled and node module loader will throw MODULE_NOT_FUOND error.
node --inspect no-exist.js
node --inspect-brk no-exist.js
node inspect no-exist.js
node --inspect
node --inspect-brk