src: check if the script file exists before starting inspector
Fixed #42600
Currently node --inspect-brk index.js
will start the inspector and wait a connection event though index.js
doesn't exist. And immediately after connected, node will throw Cannot 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.
v17.9.0 | This PR | |
---|---|---|
node --inspect no-exist.js |
Enable inspector agent & MODULE_NOT_FOUND error | MODULE_NOT_FOUND error |
node --inspect-brk no-exist.js |
Enable inspector agent | MODULE_NOT_FOUND error |
node inspect no-exist.js |
Enable inspector agent but commands fail | MODULE_NOT_FOUND error in a child process |
node --inspect |
Enable inspector agent | Enable inspector agent |
node --inspect-brk |
Enable inspector agent | Enable inspector agent |