GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — inspector: document bad usage for --inspect-port · tmarshall/node@3954ea9

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc
    • api
      • cli.md
    • node.1
  • src
    • node.cc
    • node_debug_options.cc
    • node_debug_options.h
  • test/parallel
    • test-cli-bad-options.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/cli.md‎

Copy file name to clipboardExpand all lines: doc/api/cli.md
+12Lines changed: 12 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,18 @@ added: v7.6.0
112112
-->
113113

114114
Activate inspector on host:port and break at start of user script.
115+
Default host:port is 127.0.0.1:9229.
116+
117+
118+
### `--inspect-port=[host:]port`
119+
<!-- YAML
120+
added: v7.6.0
121+
-->
122+
123+
Set the host:port to be used when the inspector is activated.
124+
Useful when activating the inspector by sending the `SIGUSR1` signal.
125+
126+
Default host is 127.0.0.1.
115127

116128

117129
### `--no-deprecation`
Collapse file

‎doc/node.1‎

Copy file name to clipboardExpand all lines: doc/node.1
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ instances for debugging and profiling. It uses the Chrome Debugging Protocol.
106106
.BR \-\-inspect-brk \fI[=[host:]port]\fR
107107
Activate inspector on host:port and break at start of user script.
108108

109+
.TP
110+
.BR \-\-inspect-port \fI=[host:]port\fR
111+
Set the host:port to be used when the inspector is activated.
112+
109113
.TP
110114
.BR \-\-no\-deprecation
111115
Silence deprecation warnings.
Collapse file

‎src/node.cc‎

Copy file name to clipboardExpand all lines: src/node.cc
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3612,6 +3612,8 @@ static void PrintHelp() {
36123612
" --inspect-brk[=[host:]port]\n"
36133613
" activate inspector on host:port\n"
36143614
" and break at start of user script\n"
3615+
" --inspect-port=[host:]port\n"
3616+
" set host:port for inspector\n"
36153617
#endif
36163618
" --no-deprecation silence deprecation warnings\n"
36173619
" --trace-deprecation show stack traces on deprecations\n"
@@ -3798,7 +3800,7 @@ static void ParseArgs(int* argc,
37983800

37993801
CheckIfAllowedInEnv(argv[0], is_env, arg);
38003802

3801-
if (debug_options.ParseOption(arg)) {
3803+
if (debug_options.ParseOption(argv[0], arg)) {
38023804
// Done, consumed by DebugOptions::ParseOption().
38033805
} else if (strcmp(arg, "--version") == 0 || strcmp(arg, "-v") == 0) {
38043806
printf("%s\n", NODE_VERSION);
Collapse file

‎src/node_debug_options.cc‎

Copy file name to clipboardExpand all lines: src/node_debug_options.cc
+14-7Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ DebugOptions::DebugOptions() :
6262
wait_connect_(false), http_enabled_(false),
6363
host_name_("127.0.0.1"), port_(-1) { }
6464

65-
bool DebugOptions::ParseOption(const std::string& option) {
65+
bool DebugOptions::ParseOption(const char* argv0, const std::string& option) {
6666
bool enable_inspector = false;
6767
bool has_argument = false;
6868
std::string option_name;
@@ -72,21 +72,28 @@ bool DebugOptions::ParseOption(const std::string& option) {
7272
if (pos == std::string::npos) {
7373
option_name = option;
7474
} else {
75-
has_argument = true;
7675
option_name = option.substr(0, pos);
7776
argument = option.substr(pos + 1);
77+
78+
if (argument.length() > 0)
79+
has_argument = true;
80+
else
81+
argument.clear();
7882
}
7983

8084
if (option_name == "--inspect") {
8185
enable_inspector = true;
8286
} else if (option_name == "--inspect-brk") {
8387
enable_inspector = true;
8488
wait_connect_ = true;
85-
} else if ((option_name != "--debug-port" &&
86-
option_name != "--inspect-port") ||
87-
!has_argument) {
88-
// only other valid possibility is --inspect-port,
89-
// which requires an argument
89+
} else if (option_name == "--debug-port" ||
90+
option_name == "--inspect-port") {
91+
if (!has_argument) {
92+
fprintf(stderr, "%s: %s requires an argument\n",
93+
argv0, option.c_str());
94+
exit(9);
95+
}
96+
} else {
9097
return false;
9198
}
9299

Collapse file

‎src/node_debug_options.h‎

Copy file name to clipboardExpand all lines: src/node_debug_options.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace node {
99
class DebugOptions {
1010
public:
1111
DebugOptions();
12-
bool ParseOption(const std::string& option);
12+
bool ParseOption(const char* argv0, const std::string& option);
1313
bool inspector_enabled() const {
1414
#if HAVE_INSPECTOR
1515
return inspector_enabled_;
Collapse file

‎test/parallel/test-cli-bad-options.js‎

Copy file name to clipboard
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
require('../common');
3+
4+
// Tests that node exits consistently on bad option syntax.
5+
6+
const assert = require('assert');
7+
const spawn = require('child_process').spawnSync;
8+
9+
requiresArgument('--inspect-port');
10+
requiresArgument('--inspect-port=');
11+
requiresArgument('--debug-port');
12+
requiresArgument('--debug-port=');
13+
requiresArgument('--eval');
14+
15+
function requiresArgument(option) {
16+
const r = spawn(process.execPath, [option], {encoding: 'utf8'});
17+
18+
assert.strictEqual(r.status, 9);
19+
20+
const msg = r.stderr.split(/\r?\n/)[0];
21+
assert.strictEqual(msg, process.execPath + ': ' + option +
22+
' requires an argument');
23+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.