-
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
net: set default highwatermark at socket creation time #48882
base: main
Are you sure you want to change the base?
Conversation
Review requested:
|
lib/net.js
Outdated
@@ -1735,11 +1735,8 @@ function Server(options, connectionListener) { | |||
if (typeof options.highWaterMark !== 'undefined') { | |||
validateNumber( | |||
options.highWaterMark, 'options.highWaterMark', | |||
0 |
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'm throwing an error if options.highWaterMark
is less than zero. Alternatively, we can fallback to a default value of undefined
.
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'm okay with being more strict and forbid negative values.
lib/net.js
Outdated
@@ -1755,7 +1752,7 @@ function Server(options, connectionListener) { | |||
this.noDelay = Boolean(options.noDelay); | |||
this.keepAlive = Boolean(options.keepAlive); | |||
this.keepAliveInitialDelay = ~~(options.keepAliveInitialDelay / 1000); | |||
this.highWaterMark = options.highWaterMark ?? getDefaultHighWaterMark(); | |||
this.highWaterMark = options.highWaterMark ?? undefined; |
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.
Theoretically this.highWaterMark = options.highWaterMark;
should suffice if we are happy with falsy values.
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.
Yes, let's accept falsy values.
Can you also please fix linter issues? |
a6dc57b
to
d6e7851
Compare
LGTM now. |
Tests are failing |
d6e7851
to
624f697
Compare
I've amended the tests. |
624f697
to
b0572e0
Compare
I've also made the procedure more evident in the documentation. |
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!
b0572e0
to
9f859b9
Compare
Fixed some linting issues. |
doc/api/http.md
Outdated
@@ -3249,7 +3249,7 @@ changes: | |||
* `highWaterMark` {number} Optionally overrides all `socket`s' | |||
`readableHighWaterMark` and `writableHighWaterMark`. This affects | |||
`highWaterMark` property of both `IncomingMessage` and `ServerResponse`. | |||
**Default:** See [`stream.getDefaultHighWaterMark()`][]. | |||
**Default:** `undefined`. Sockets will use the default watermark value at the time the request arrives. See [`stream.getDefaultHighWaterMark()`][]. |
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 would keep it consistent and add a line break after 80 characters.
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.
The lint job fails for this reason.
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.
Addressed
9f859b9
to
18696df
Compare
This needs a rebase to fix the git conflicts. |
18696df
to
3a500ba
Compare
Thanks. Rebased |
This PR is to make a recent code changes backwards compatible with previous releases of Node.JS, as depicted in #47405 (comment)