-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
module: move options checks from C++ to JS #19822
Conversation
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.
LGTM with green CI and CITGM
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.
Great to see negative diff :)
if ((prop >> 0) !== prop) { | ||
throw new ERR_OUT_OF_RANGE(propName, '32-bit integer', prop); | ||
} | ||
} |
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.
Does this not belong somewhere a little more generic perhaps? Somewhat surprising there isn't already something for this too?
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 agree, especially since I copied this function from another file. I'll look into bringing together type validation functions in another PR if that's fine for you.
let timeout = options.timeout; | ||
if (timeout === undefined) { | ||
timeout = -1; | ||
} else if (!Number.isInteger(timeout) || timeout <= 0) { |
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.
Should timeout also run through validateInteger?
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.
The check is a bit different. timeout
may not be negative, while validateInteger allows negative values.
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.
ModuleWrap::Evaluate could use a signature comment but otherwise looks ok
Landed in 77b52fd |
PR-URL: #19822 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com>
Follow-up of #19398
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes/cc @joyeecheung @TimothyGu @devsnek @nodejs/tsc