Skip to content
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

inspector: document bad usage for --inspect-port #12581

Closed

Conversation

@sam-github
Copy link
Member

commented Apr 22, 2017

Document --inspect-port, and fix the reporting for when it is misused.

The option requires an argument, but when the argument was omitted, the
error message incorrectly reported --inspect-port as being bad, as if
was not supported at all:

% node --inspect-port
node: bad option: --inspect-port
% node --none-such
node: bad option: --none-such

It is now correctly reported as requiring an argument:

% ./node --inspect-port
./node: --inspect-port requires an argument
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

inspector

@sam-github sam-github referenced this pull request Apr 22, 2017
4 of 4 tasks complete
doc/api/cli.md Outdated
-->

Set the host:port to be used when the inspector is activated.
Useful when the activating the inspector by sending the `SIGUSR1` signal.

This comment has been minimized.

Copy link
@richardlau

richardlau Apr 22, 2017

Member

Extra the.

@mscdex mscdex added the inspector label Apr 22, 2017

@bnoordhuis
Copy link
Member

left a comment

Needs tests. Also, I would handle it in node_debug_options.cc, not node.cc.

@sam-github

This comment has been minimized.

Copy link
Member Author

commented Apr 22, 2017

I would handle it in node_debug_options.cc, not node.cc.

The only way to do that is to exit(9) from node_debug_options.cc, are you OK with that?

The structure of the code suggests to me that is not intended, but I don't understand why the debug options parsing was broken out into of the main option parsing loop in the first place. Because it was broken out into a function that returns boolean it can only indicate consumed/not consumed, and has no way of returning an error state. I could change the return to an int: 0 = consumed, 1 = not consumed, -1 means error -- but then how to return the specific error string? Add a return string arg, too? Seems a mess.

@bnoordhuis

This comment has been minimized.

Copy link
Member

commented Apr 22, 2017

The only way to do that is to exit(9) from node_debug_options.cc, are you OK with that?

Yes. There is at least one other exit statement in that file.

@joshgav

This comment has been minimized.

Copy link
Member

commented Apr 22, 2017

IIRC I didn't document --inspect-port while working on this cause I thought it could use some review before becoming public. Also, we may want to clarify its use cases and whether they can be met with the --inspect=9229 syntax (again IIRC 😉 ).

@sam-github

This comment has been minimized.

Copy link
Member Author

commented Apr 23, 2017

I think inspect-port is for use with SIGUSR1, ultimately, whereas --inspect=9999 will actually activate the inspector.

@sam-github

This comment has been minimized.

Copy link
Member Author

commented Apr 24, 2017

@bnoordhuis shouldn't that be exit(9)? What's with the 12? This and node_revert.cc seem to be the only uses of 12 in node, the other CLI arg errors I've found are 9.

@sam-github

This comment has been minimized.

Copy link
Member Author

commented Apr 24, 2017

@richardlau

This comment has been minimized.

Copy link
Member

commented Apr 28, 2017

Exit code 12 is specific to the --debug, --inspect and/or --debug-brk options (https://nodejs.org/api/process.html#process_exit_codes)

@bnoordhuis

This comment has been minimized.

Copy link
Member

commented May 15, 2017

@sam-github Rebase needed.

@sam-github sam-github force-pushed the sam-github:document-inspect-port-usage branch 2 times, most recently May 16, 2017

@sam-github

This comment has been minimized.

Copy link
Member Author

commented May 17, 2017

@sam-github

This comment has been minimized.

Copy link
Member Author

commented May 17, 2017

@sam-github sam-github force-pushed the sam-github:document-inspect-port-usage branch May 17, 2017

@sam-github

This comment has been minimized.

Copy link
Member Author

commented May 17, 2017

argh, lint error if you don't require common, lint error if you require it and don't use it.

ci: https://ci.nodejs.org/job/node-test-pull-request/8133/

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

// Tests that node exits consistently on bad option syntax.

common.noop(); // Avoid lint errors if common is not required, or not used.

This comment has been minimized.

Copy link
@aqrln

aqrln May 17, 2017

Member

Instead of doing this, you can just write require('../common'); on the line 2 and don't assign the result of require anywhere.

@sam-github

This comment has been minimized.

Copy link
Member Author

commented May 17, 2017

inspector: document bad usage for --inspect-port
Document --inspect-port, and fix the reporting for when it is misused.

The option requires an argument, but when the argument was omitted, the
error message incorrectly reported --inspect-port as being bad, as if
was not supported at all:

    % node --inspect-port
    node: bad option: --inspect-port
    % node --none-such
    node: bad option: --none-such

It is now correctly reported as requiring an argument:

    % ./node --inspect-port
    ./node: --inspect-port requires an argument

@sam-github sam-github force-pushed the sam-github:document-inspect-port-usage branch to 4a773f5 May 18, 2017

@sam-github

This comment has been minimized.

Copy link
Member Author

commented May 18, 2017

@sam-github

This comment has been minimized.

Copy link
Member Author

commented May 18, 2017

OK, nice and green, @bnoordhuis

Requested changes have been made.

@sam-github

This comment has been minimized.

Copy link
Member Author

commented May 24, 2017

Landed in 6c45b26

edit by @addaleax: force-pushed, now landed in 3954ea9

@sam-github sam-github closed this May 24, 2017

@sam-github sam-github deleted the sam-github:document-inspect-port-usage branch May 24, 2017

addaleax added a commit that referenced this pull request May 24, 2017
inspector: document bad usage for --inspect-port
Document --inspect-port, and fix the reporting for when it is misused.

The option requires an argument, but when the argument was omitted, the
error message incorrectly reported --inspect-port as being bad, as if
was not supported at all:

    % node --inspect-port
    node: bad option: --inspect-port
    % node --none-such
    node: bad option: --none-such

It is now correctly reported as requiring an argument:

    % ./node --inspect-port
    ./node: --inspect-port requires an argument

PR-URL: #12581
Reviewed-By: James M Snell <jasnell@gmail.com>
jasnell added a commit that referenced this pull request May 25, 2017
inspector: document bad usage for --inspect-port
Document --inspect-port, and fix the reporting for when it is misused.

The option requires an argument, but when the argument was omitted, the
error message incorrectly reported --inspect-port as being bad, as if
was not supported at all:

    % node --inspect-port
    node: bad option: --inspect-port
    % node --none-such
    node: bad option: --none-such

It is now correctly reported as requiring an argument:

    % ./node --inspect-port
    ./node: --inspect-port requires an argument

PR-URL: #12581
Reviewed-By: James M Snell <jasnell@gmail.com>
jasnell added a commit that referenced this pull request May 28, 2017
inspector: document bad usage for --inspect-port
Document --inspect-port, and fix the reporting for when it is misused.

The option requires an argument, but when the argument was omitted, the
error message incorrectly reported --inspect-port as being bad, as if
was not supported at all:

    % node --inspect-port
    node: bad option: --inspect-port
    % node --none-such
    node: bad option: --none-such

It is now correctly reported as requiring an argument:

    % ./node --inspect-port
    ./node: --inspect-port requires an argument

PR-URL: #12581
Reviewed-By: James M Snell <jasnell@gmail.com>
@jasnell jasnell referenced this pull request May 28, 2017
@gibfahn gibfahn referenced this pull request Jun 15, 2017
2 of 3 tasks complete
@MylesBorins

This comment has been minimized.

Copy link
Member

commented Jul 17, 2017

I don't believe this is applicable to v6.x

Please feel free to change label if I am mistaken

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.