Skip to content

Commit 626a07d

Browse files
Eugene Ostroukhovofrobots
authored andcommitted
inspector: restore 9229 as a default port
Some tools are now relying on 9229 to be node.js "inspector" port (I see Chrome extensions, some online blog posts, etc.) Also, having same default port values for old and new protocols may lead to some confusion, e.g. when tools are trying to autodiscover debuggable Node instances. This is a partial revert of 9f1f7e2. This commit preserves the fix for issue #8201 bringing back the behavior that the old and new protocols run on different ports.run on different ports. PR-URL: #8550 Reviewed-By: ofrobots - Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com>
1 parent b4a249f commit 626a07d

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/node.cc

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ static const bool use_inspector = false;
147147
static bool use_debug_agent = false;
148148
static bool debug_wait_connect = false;
149149
static std::string* debug_host; // coverity[leaked_storage]
150-
static int debug_port = 5858;
150+
static const int default_debugger_port = 5858;
151+
static const int default_inspector_port = 9229;
152+
static int debug_port = -1;
151153
static const int v8_default_thread_pool_size = 4;
152154
static int v8_thread_pool_size = v8_default_thread_pool_size;
153155
static bool prof_process = false;
@@ -2874,7 +2876,10 @@ static Local<Object> GetFeatures(Environment* env) {
28742876

28752877
static void DebugPortGetter(Local<Name> property,
28762878
const PropertyCallbackInfo<Value>& info) {
2877-
info.GetReturnValue().Set(debug_port);
2879+
int port = debug_port;
2880+
if (port < 0)
2881+
port = use_inspector ? default_inspector_port : default_debugger_port;
2882+
info.GetReturnValue().Set(port);
28782883
}
28792884

28802885

@@ -3765,15 +3770,17 @@ static void DispatchMessagesDebugAgentCallback(Environment* env) {
37653770
static void StartDebug(Environment* env, const char* path, bool wait) {
37663771
CHECK(!debugger_running);
37673772
if (use_inspector) {
3768-
debugger_running = v8_platform.StartInspector(env, path, debug_port, wait);
3773+
debugger_running = v8_platform.StartInspector(env, path,
3774+
debug_port >= 0 ? debug_port : default_inspector_port, wait);
37693775
} else {
37703776
env->debugger_agent()->set_dispatch_handler(
37713777
DispatchMessagesDebugAgentCallback);
37723778
const char* host = debug_host ? debug_host->c_str() : "127.0.0.1";
3779+
int port = debug_port >= 0 ? debug_port : default_debugger_port;
37733780
debugger_running =
3774-
env->debugger_agent()->Start(host, debug_port, wait);
3781+
env->debugger_agent()->Start(host, port, wait);
37753782
if (debugger_running == false) {
3776-
fprintf(stderr, "Starting debugger on %s:%d failed\n", host, debug_port);
3783+
fprintf(stderr, "Starting debugger on %s:%d failed\n", host, port);
37773784
fflush(stderr);
37783785
return;
37793786
}

0 commit comments

Comments
 (0)