-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
undefined port should trigger a RangeError when launching a server #14205
Comments
if you change that one liner to |
Hi Evan, my initial code was: // start the server
console.log('process.env.PORT', process.env.PORT)
app.listen(process.env.PORT, function () {
console.log(`Server is running on port ${port}`)
}) In that context |
yes, it doesn't complain because when a port is undefined, we treat it like it's |
This behavior has recently changed, maybe a few lines in that section of the docs would be good, because I just tried it with node 8.x and 6.x. In node 6 EDIT: we have been using |
This is a regression, IMO.
6.x and 8.x doing the opposite of each other doesn't look intentional, both should behave like 4.x.
|
@sam-github I agree. I didn't realize this behavior had changed |
@cjihrig I'm working on fix for 6.x, FYI /cc @nodejs/lts |
Existing test only covered ports pass as options, add tests for argument behaviour to avoid regressions. Ref: nodejs#14205
For consistency with 4.x and 8.x. This commit also contains a forward port of #14232 to confirm that 4.x and 6.x behave identically with respect to the port argument. PR-URL: #14234 Refs: #14205 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
For consistency with 4.x and 8.x. This commit also contains a forward port of #14232 to confirm that 4.x and 6.x behave identically with respect to the port argument. PR-URL: #14234 Refs: #14205 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
For consistency with 4.x and 8.x. This commit also contains a forward port of #14232 to confirm that 4.x and 6.x behave identically with respect to the port argument. PR-URL: #14234 Refs: #14205 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
For consistency with 4.x and 8.x. This commit also contains a forward port of nodejs#14232 to confirm that 4.x and 6.x behave identically with respect to the port argument. PR-URL: nodejs#14234 Refs: nodejs#14205 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
For consistency with 4.x and 8.x. This commit also contains a forward port of #14232 to confirm that 4.x and 6.x behave identically with respect to the port argument. Backport-PR-URL: #14234 PR-URL: #14234 Refs: #14205 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
This commit fixes a regression around the handling of null as the port passed to Server#listen(). With this commit, null, undefined, and 0 have the same behavior, which was the case in Node 4. Fixes: nodejs#14205 PR-URL: nodejs#14221 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit fixes a regression around the handling of null as the port passed to Server#listen(). With this commit, null, undefined, and 0 have the same behavior, which was the case in Node 4. Fixes: nodejs/node#14205 PR-URL: nodejs/node#14221 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit fixes a regression around the handling of null as the port passed to Server#listen(). With this commit, null, undefined, and 0 have the same behavior, which was the case in Node 4. Fixes: #14205 PR-URL: #14221 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
7.9.0
Darwin MacBook-Air-de-paul-7.local 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64
Hi guys,
On my version/platform it is possible to launch a server with an undefined port. This is misleading given that there's no error message and you believe the server is working but in fact it does not listen at all. On other versions it throws a RangeError.
A complete history can be found here: expressjs/express#3364 but Doug (https://github.com/dougwilson) gave me this one liner which makes it easy to test:
Thanks,
Paul
The text was updated successfully, but these errors were encountered: