Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

juanarbol
Copy link
Member

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

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

@nodejs-github-bot nodejs-github-bot added the net Issues and PRs related to the net subsystem. label Jan 13, 2020
@@ -1535,6 +1535,7 @@ function onconnection(err, clientHandle) {
}

if (self.maxConnections && self._connections >= self.maxConnections) {
self.emit('maxConnections');
Copy link
Member

Choose a reason for hiding this comment

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

@mcollina @addaleax @BridgeAR ... would be good to get some more opinions on this... do we want to communicate this case this way or using an error instead?

Copy link
Member

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.

Copy link
Member

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 :-)

Copy link
Member

@mcollina mcollina left a 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');
Copy link
Member

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.

Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

Nice, LGTM

@sam-github
Copy link
Contributor

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 error event is not desireable because it shouldn't be handled as a server-side error.

I'd imagine something like a .emit('clientRejected', new MaxExceededError(), socket).

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 'clientRejected' makes that more clear, as would a bit more information in the docs.

Also, the .maxConnections docs should be cross-linked back to the event that gets emitted when the constraint is overrun.

Copy link
Member

@Trott Trott left a 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).

@Trott Trott added the semver-minor PRs that contain new features and should be released in the next minor version. label Jan 14, 2020
@juanarbol
Copy link
Member Author

ping @Trott

@juanarbol
Copy link
Member Author

Closing

@juanarbol juanarbol closed this Mar 24, 2020
@juanarbol juanarbol deleted the net-event-connection-limit branch January 19, 2021 16:28
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-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants