-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
net: type check createServer options object #2904
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
net: type check createServer options object #2904
Conversation
net.createServer('aPipe') and net.createServer(8080) are mistakes, and
now throw a TypeError instead of silently being treated as an object.
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.
Use const
lib/net.js
Outdated
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.
Space between if and (
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.
Nit: Meh, maybe not so much. typeof null returns 'object' so you can skip the check for options == null unless the intention is for the not-strict equality to allow undefined, in which case I imagine checking for undefined would be more clear.== null is pretty idiomatic for "null or undefined".
|
LGTM |
|
Is this semver-major with the throw or are we considering this a bugfix? |
|
Seems like a bug fix to me. Currently, if you passed something like |
|
Ah that makes sense |
|
So I guess the behavior would still be changing if |
|
Yea I guess so. Same for |
|
LGTM minus the nit that @cjihrig pointed out |
|
Anything blocking this? |
|
@benjamingr just one style nit, and a CI run, as far as I can tell. If you want, you can address the style nit and land it, assuming CI is happy. |
|
We also might want to squash the commits no? |
|
Yes |
|
Sure, I'll shape it up and land it tomorrow |
|
The linter is angry for missing a space between the |
net.createServer('aPipe') and net.createServer(8080) are mistakes,
and now throw a TypeError instead of silently being treated as an
object.
PR-URL: #2904
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
|
Landed in a78b334 . Thanks. |
|
Marked as a semver-major because it adds a new throw. |
|
@evanlucas make sure you catch this for v5.8.1 ^ |
|
@Fishrock123 semver-major though? |
|
See the discussion above @jasnell @Fishrock123 :
|
|
hmm... not sure about that. If I passed 5 as options, |
|
That's right, I tend to agree. |
net.createServer('aPipe') and net.createServer(8080) are mistakes, and
now throw a TypeError instead of silently being treated as an object.