You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
--inspect should automatically get a new port if default port 9229 is already in use #28457
Is your feature request related to a problem? Please describe.
Image a kubernetes cluster using minikube with 50 micro-services on a dev environment, each micro-service is launched using the --inspect param, so we can remotely debug the services, like using vs-code kubernetes extension. In that case, just using --inspect or --inspect-brk will try to use the same inspector port 9229 for each micro-service, resulting on startup errors and services not running at all.
Describe the solution you'd like
--inspect and --inspect-brk should try the default port 9229, if the port is already in use, automatically get a random port that is not in use, or just increment the current port number until the port is available.
Describe alternatives you've considered
Manually setting an unique inspect port for each service. It means we must manually hard-code each unique inspector port for each micro-service config.
Apologies for the miscommunication. I wrote earlier that it didn't work (and then deleted the comment because I found out soon after that I was wrong).
The error I was running into was produced by a userland thing, not node itself
Activity
cjihrig commentedon Jun 27, 2019
If you pass
0as the port number, you'll get a random, available port.gustavomassa commentedon Jun 27, 2019
@cjihrig Thank you! I did not know about passing 0, the inspector documentation needs to be updated.
https://nodejs.org/en/docs/inspector
https://nodejs.org/en/docs/guides/debugging-getting-started/
command: ["node", "--max_old_space_size=512", "--nolazy", "--no-warnings", "--expose-gc", "--inspect=0.0.0.0:0", "dist/src/Main.js"]vhuty commentedon Jul 8, 2024
The "zero-port behavior" is not documented at the moment. Is it still valid?
avivkeller commentedon Jul 9, 2024
That behavior is still valid, I've opened a PR to document it: #53782
steelbrain commentedon Jul 9, 2024
Apologies for the miscommunication. I wrote earlier that it didn't work (and then deleted the comment because I found out soon after that I was wrong).
The error I was running into was produced by a userland thing, not node itself
juanbomfim22 commentedon Oct 7, 2024
That's fantastic.
Important
The port should be a number, beware of passing a string as '0'.