-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: split the HostPort being used and the one parsed from CLI #24772
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -243,12 +243,12 @@ void Open(const FunctionCallbackInfo<Value>& args) { | |
|
||
if (args.Length() > 0 && args[0]->IsUint32()) { | ||
uint32_t port = args[0].As<Uint32>()->Value(); | ||
agent->options()->host_port.port = port; | ||
agent->host_port()->set_port(static_cast<int>(port)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The cast can overflow. Better to check that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was already possible to overflow before since we were assigning uint32_t to int anyways. I think we'd better turn |
||
} | ||
|
||
if (args.Length() > 1 && args[1]->IsString()) { | ||
Utf8Value host(env->isolate(), args[1].As<String>()); | ||
agent->options()->host_port.host_name = *host; | ||
agent->host_port()->set_host(*host); | ||
} | ||
|
||
if (args.Length() > 2 && args[2]->IsBoolean()) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's kind of gnarly to have those fields duplicated. Can that be fixed somehow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried a few approaches, e.g. splitting the options into two
Options
subclasses instead of putting them in oneDebugOptions
, that makes the parsing code even more complicated because we have combined arguments like--inspect-brk=127.0.0.1:0
. Also, the HostPort in DebugOptions are actually per-process (because those are parsed from CLI) whereas the shared HostPort are per-Environment (since the inspector agents are per-Environment). Conceptually, they are not really duplicates because the CLI ones are "snapshots" of the parsed arguments which may still be useful themselves (e.g. in tests)