-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Prevent multiple calls to Server.listen #6238
Conversation
}, /cannot call "listen" multiple times/i); | ||
|
||
process.on('exit', () => { | ||
// Is this needed? assert.equal(server.address().port, 8080); |
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.
Is this necessary?
@@ -0,0 +1,17 @@ | |||
const assert = require('assert'); |
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.
../common
should be the first required line.
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.
Also run the test in strict mode
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.
Thanks @thefourtheye - added ../common
and strict mode.
Conservatively marking this as a major due to the change in behavior but it's likely just fine as a minor. Feel free to downgrade if appropriate. |
lib/net.js
Outdated
@@ -1300,6 +1300,11 @@ function listen(self, address, port, addressType, backlog, fd, exclusive) { | |||
Server.prototype.listen = function() { | |||
var self = this; | |||
|
|||
if (self._listenHasBeenCalled) | |||
throw new Error('cannot call "listen" multiple times'); |
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.
Perhaps, 'listen() cannot be called multiple times.'
Integrated feedback from @jasnell @thefourtheye @estliberitas I am not sure on this: does anyone think this needs documentation? I'm wondering because of the semver-major tag... I know that's not necessarily the point of semver, I was just thinking this was 'minor' - and only affected accidentally 'working' edge-case/broken code. |
I've run the tests on my Debian 7 & 8 systems, as well as on OSX... All pass. @jasnell I'm trying to pull up the 'TAP Test Results' to see failure/details... but it is not coming up. |
Seeing this:
|
@jasnell Am I not using |
It's in a different test ... Do |
Basically, you'll need to update any other tests that happen to be impacted by this change |
I was hitting several fails on other tests, but I think I figured out a way to only require changes to 1 other test - essentially I just throw the error later. |
7da4fd4
to
c7066fb
Compare
c133999
to
83c7a88
Compare
I believe this is no longer necessary. /cc @bnoordhuis |
Checklist
Affected core subsystem(s)
net
Description of change
Minimal attempt to resolve #6190
Added
_listenHasBeenCalled
as suggested by @trevnorris