Skip to content

Conversation

@sam-github
Copy link
Contributor

net.createServer('aPipe') and net.createServer(8080) are mistakes, and
now throw a TypeError instead of silently being treated as an object.

net.createServer('aPipe') and net.createServer(8080) are mistakes, and
now throw a TypeError instead of silently being treated as an object.
@sam-github sam-github added the net Issues and PRs related to the net subsystem. label Sep 16, 2015
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space between if and (

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: 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. Meh, maybe not so much. == null is pretty idiomatic for "null or undefined".

@cjihrig
Copy link
Contributor

cjihrig commented Sep 17, 2015

LGTM

@evanlucas
Copy link
Contributor

Is this semver-major with the throw or are we considering this a bugfix?

@cjihrig
Copy link
Contributor

cjihrig commented Sep 18, 2015

Seems like a bug fix to me. Currently, if you passed something like 5 as options, you'd hit options = options || {};, and then later crash on this.allowHalfOpen = options.allowHalfOpen || false;.

@evanlucas
Copy link
Contributor

Ah that makes sense

@evanlucas
Copy link
Contributor

So I guess the behavior would still be changing if false were passed?

@cjihrig
Copy link
Contributor

cjihrig commented Sep 18, 2015

Yea I guess so. Same for NaN, as undocumented as it may be :-)

@evanlucas
Copy link
Contributor

LGTM minus the nit that @cjihrig pointed out

@benjamingr
Copy link
Member

Anything blocking this?

@cjihrig
Copy link
Contributor

cjihrig commented Mar 14, 2016

@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.

@whitlockjc
Copy link
Contributor

We also might want to squash the commits no?

@cjihrig
Copy link
Contributor

cjihrig commented Mar 14, 2016

Yes

@benjamingr
Copy link
Member

Sure, I'll shape it up and land it tomorrow

@benjamingr
Copy link
Member

@benjamingr
Copy link
Member

The linter is angry for missing a space between the if and a ( - otherwise tests pass - I'll fix this locally.

benjamingr pushed a commit that referenced this pull request Mar 15, 2016
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]>
@benjamingr
Copy link
Member

Landed in a78b334 . Thanks.

@benjamingr benjamingr closed this Mar 15, 2016
@jasnell jasnell added the semver-major PRs that contain breaking changes and should be released in the next major version. label Mar 15, 2016
@jasnell
Copy link
Member

jasnell commented Mar 15, 2016

Marked as a semver-major because it adds a new throw.

@Fishrock123
Copy link
Contributor

@evanlucas make sure you catch this for v5.8.1 ^

@evanlucas
Copy link
Contributor

@Fishrock123 semver-major though?

@benjamingr
Copy link
Member

See the discussion above @jasnell @Fishrock123 :

Seems like a bug fix to me. Currently, if you passed something like 5 as options, you'd hit options = options || {};, and then later crash on this.allowHalfOpen = options.allowHalfOpen || false;.

@jasnell
Copy link
Member

jasnell commented Mar 15, 2016

hmm... not sure about that. If I passed 5 as options, options = options || {} would mean options = 5, which means this.allowHalfOpen = options.allowHalfOpen || false would not crash, it would simply resolve to this.allowHalfOpen = false.

@benjamingr
Copy link
Member

That's right, I tend to agree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

net Issues and PRs related to the net subsystem. semver-major PRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants