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

net: set default highwatermark at socket creation time #48882

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lukiano
Copy link

@lukiano lukiano commented Jul 22, 2023

This PR is to make a recent code changes backwards compatible with previous releases of Node.JS, as depicted in #47405 (comment)

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. net Issues and PRs related to the net subsystem. labels Jul 22, 2023
lib/net.js Outdated
@@ -1735,11 +1735,8 @@ function Server(options, connectionListener) {
if (typeof options.highWaterMark !== 'undefined') {
validateNumber(
options.highWaterMark, 'options.highWaterMark',
0
Copy link
Author

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.

Copy link
Contributor

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;
Copy link
Author

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.

Copy link
Contributor

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.

@ShogunPanda
Copy link
Contributor

Can you also please fix linter issues?

@lukiano lukiano force-pushed the fix/watermark-at-socket-creation branch from a6dc57b to d6e7851 Compare July 22, 2023 12:37
@ShogunPanda
Copy link
Contributor

LGTM now.
Can you also update docs?

@mcollina
Copy link
Member

Tests are failing

@lukiano lukiano force-pushed the fix/watermark-at-socket-creation branch from d6e7851 to 624f697 Compare July 24, 2023 11:45
@lukiano
Copy link
Author

lukiano commented Jul 24, 2023

I've amended the tests.

@lukiano lukiano force-pushed the fix/watermark-at-socket-creation branch from 624f697 to b0572e0 Compare July 24, 2023 11:49
@lukiano
Copy link
Author

lukiano commented Jul 24, 2023

I've also made the procedure more evident in the documentation.

Copy link
Contributor

@ShogunPanda ShogunPanda left a comment

Choose a reason for hiding this comment

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

LGTM!

@lukiano lukiano force-pushed the fix/watermark-at-socket-creation branch from b0572e0 to 9f859b9 Compare July 24, 2023 20:14
@lukiano
Copy link
Author

lukiano commented Jul 24, 2023

Fixed some linting issues.

@lpinca lpinca added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jul 27, 2023
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()`][].
Copy link
Member

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.

Copy link
Member

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.

Copy link
Author

Choose a reason for hiding this comment

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

Addressed

@lukiano lukiano force-pushed the fix/watermark-at-socket-creation branch from 9f859b9 to 18696df Compare July 28, 2023 10:08
@lpinca lpinca added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 28, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 28, 2023
@nodejs-github-bot
Copy link
Collaborator

@lpinca lpinca added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 10, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 10, 2023
@nodejs-github-bot
Copy link
Collaborator

@aduh95
Copy link
Contributor

aduh95 commented Sep 29, 2023

This needs a rebase to fix the git conflicts.

@lukiano lukiano force-pushed the fix/watermark-at-socket-creation branch from 18696df to 3a500ba Compare September 29, 2023 11:05
@lukiano
Copy link
Author

lukiano commented Sep 29, 2023

Thanks. Rebased

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 30, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 30, 2023
@nodejs-github-bot
Copy link
Collaborator

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 30, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 30, 2023
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 26, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 26, 2023
@nodejs-github-bot
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-ci PRs that need a full CI run. net Issues and PRs related to the net subsystem. semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants