-
Notifications
You must be signed in to change notification settings - Fork 30.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
support maxConnections event on net server #31337
Conversation
@@ -1535,6 +1535,7 @@ function onconnection(err, clientHandle) { | |||
} | |||
|
|||
if (self.maxConnections && self._connections >= self.maxConnections) { | |||
self.emit('maxConnections'); |
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.
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 think this is totally fine as is.
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.
Works for me too then :-)
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
@@ -1535,6 +1535,7 @@ function onconnection(err, clientHandle) { | |||
} | |||
|
|||
if (self.maxConnections && self._connections >= self.maxConnections) { | |||
self.emit('maxConnections'); |
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 think this is totally fine as is.
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.
Nice, LGTM
I'm not going to block this, but I think following the API pattern of https://nodejs.org/api/http.html#http_event_clienterror would make sense for this if, as in the HTTP case, emitting an I'd imagine something like a Also, the docs don't make it clear when the event in this PR is emitted. Level-triggered? Every time a client is rejected? An event name like Also, the |
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.
This is a temporary block to give more time to discuss @sam-github's suggestions. I know they said their comments are not blocking, but there's no rush here, this is a new feature, and we should aim to get it right the first time (and introduce it as Experimental if we think it's likely to have significant changes as we iterate).
ping @Trott |
Closing |
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesI think this could help with the developer experience, when the server connection limit is reached there is not feedback.
At this point, the event is emitted every new connection over the limit, I mean, if the limit is 10, and we get 12 connections, the event will be emitted twice.