Skip to content

Conversation

@amyssnippet
Copy link
Contributor

@amyssnippet amyssnippet commented Jan 24, 2026

this PR implements socket.setTypeOfService(tos) and socket.getTypeOfService() in net.Socket. it needed this to support DSCP tagging (QoS) for traffic prioritization, which wasn't previously exposed in the JS API. for the implementation:

  • I added the logic in tcp_wrap.cc to attempt IP_TOS first, and fallback to IPV6_TCLASS if that fails. This handles both IPv4 and IPv6 sockets automatically without needing a separate flag.
  • Windows returns UV_ENOSYS for now since the headers/implementation differ there.
  • Added a new test file (test-net-socket-tos.js) to verify input validation and ensure the values are actually set on supported platforms.

Fixes: #61489

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Jan 24, 2026
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.

Good work. Can you add the documentation?

@mcollina mcollina requested a review from ronag January 24, 2026 13:16
@mcollina mcollina added the semver-minor PRs that contain new features and should be released in the next minor version. label Jan 24, 2026
@amyssnippet amyssnippet requested a review from mcollina January 24, 2026 13:41
@amyssnippet amyssnippet mentioned this pull request Jan 24, 2026
@amyssnippet amyssnippet requested a review from mcollina January 24, 2026 14:34
@amyssnippet
Copy link
Contributor Author

Thanks @mcollina , is this ready to be merged? Please let me know if there is anything else you need me to adjust.

@ronag ronag added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 25, 2026
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 25, 2026
@nodejs-github-bot
Copy link
Collaborator

@ronag
Copy link
Member

ronag commented Jan 25, 2026

@mcollina I'm confused by the CI failures. Any ideas? Or just flaky?

@richardlau richardlau added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Jan 31, 2026
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Jan 31, 2026
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/61503
✔  Done loading data for nodejs/node/pull/61503
----------------------------------- PR info ------------------------------------
Title      net: add setTypeOfService and getTypeOfService to Socket (#61503)
Author     Amol Yadav  <amyssnipet@yahoo.com> (@amyssnippet, first-time contributor)
Branch     amyssnippet:fix/61489 -> nodejs:main
Labels     c++, semver-minor, lib / src, author ready, commit-queue-squash
Commits    34
 - net: add setTOS and getTOS to Socket
 - added doc
 - fixed some lint issues
 - already complete with validation and platform specific tests
 - added: REPLACEME
 - common.mustCall used
 - undo: unrelated header was removed irrelevantly
 - fix: resolve windows compilation and linter issues
 - rollback to tcp only
 - fix: ensure getTOS returns numeric default when handle lacks getTOS
 - fix: handle setTOS errors in afterConnect and use options.tos
 - fix: capture errno immediately after getsockopt failures
 - fix: use correct length type for Windows getsockopt and fix DSCP mask…
 - fix: validate options.tos in constructor
 - fix: use validateInt32 for options.tos and standardize GetTOS error
 - fix: remove unused errno_val in TCPWrap::GetTOS POSIX path
 - test: add boundary value assertions for TOS
 - test: add pre-connect TOS caching test
 - doc: add notes for setTOS and getTOS about pre-connect caching and OS…
 - fix: import UV_EBADF and remove duplicate mask declaration
 - fix: update TOS cache when handle lacks setTOS
 - doc: clarify pre-connect TOS test comment
 - refined: comments
 - doc: remove prohibited 'Note that' phrases
 - fix: reorder includes for Windows compatibility and add missing POSIX…
 - fix: resolve windows header order and doc lint errors
 - feat: rename setTOS/getTOS to setTypeOfService/getTypeOfService for A…
 - fix: update internal handle calls to use new TypeOfService method names
 - win vs2022 ci fix
 - added: todo for libuv api
 - fixed:win vs2022 lint ci
 - feat: rename C++ methods from SetTOS/GetTOS to SetTypeOfService/GetTy…
 - docs: update net.md for typeOfService option and fix lib/net.js const…
 - Apply suggestions from code review
Committers 2
 - Amol Yadav <amyssnipet@yahoo.com>
 - GitHub <noreply@github.com>
PR-URL: https://github.com/nodejs/node/pull/61503
Fixes: https://github.com/nodejs/node/issues/61489
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/61503
Fixes: https://github.com/nodejs/node/issues/61489
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
--------------------------------------------------------------------------------
   ℹ  This PR was created on Sat, 24 Jan 2026 11:11:33 GMT
   ✔  Approvals: 3
   ✔  - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/61503#pullrequestreview-3731022920
   ✔  - Robert Nagy (@ronag) (TSC): https://github.com/nodejs/node/pull/61503#pullrequestreview-3730004460
   ✔  - Anna Henningsen (@addaleax): https://github.com/nodejs/node/pull/61503#pullrequestreview-3711651185
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2026-01-30T23:57:17Z: https://ci.nodejs.org/job/node-test-pull-request/71128/
- Querying data for job/node-test-pull-request/71128/
✔  Build data downloaded
   ✔  Last Jenkins CI successful
   ⚠  PR author is a new contributor: @amyssnippet(amyssnipet@yahoo.com)
   ⚠  - commit d53c0157fc93 is authored by ronagy@icloud.com
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/21536896438

@juanarbol
Copy link
Member

juanarbol commented Jan 31, 2026

Apparently commit-queue job is failing because of d53c015, which was committed by somebody else. And triggered because a new contributor.

Refs: https://github.com/nodejs/node-core-utils/blob/19b468ad088a8200eabdc94a96f58a6027e2fc11/lib/pr_checker.js#L84

@amyssnippet
Copy link
Contributor Author

amyssnippet commented Jan 31, 2026

Apparently commit-queue job is failing because of d53c015, which was committed by somebody else. And triggered because a new contributor.

Refs: https://github.com/nodejs/node-core-utils/blob/19b468ad088a8200eabdc94a96f58a6027e2fc11/lib/pr_checker.js#L84

so what should i do now?? @ronag has did that commit himself and he is a member too

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

@amyssnippet
Copy link
Contributor Author

@ronag and @mcollina , why the merging failed??

@ronag
Copy link
Member

ronag commented Feb 2, 2026

No idea. Not familiar with that error or how to fix it.

@amyssnippet
Copy link
Contributor Author

i guess @juanarbol told it here

Apparently commit-queue job is failing because of d53c015, which was committed by somebody else. And triggered because a new contributor.

Refs: https://github.com/nodejs/node-core-utils/blob/19b468ad088a8200eabdc94a96f58a6027e2fc11/lib/pr_checker.js#L84

@ronag
Copy link
Member

ronag commented Feb 2, 2026

Still not familiar with it nor do I understand how to fix it. Hopefully someone else will jump in.

@aduh95 aduh95 added commit-queue Add this label to land a pull request using GitHub Actions. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Feb 2, 2026
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Feb 2, 2026
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/61503
✔  Done loading data for nodejs/node/pull/61503
----------------------------------- PR info ------------------------------------
Title      net: add setTypeOfService and getTypeOfService to Socket (#61503)
Author     Amol Yadav  <amyssnipet@yahoo.com> (@amyssnippet, first-time contributor)
Branch     amyssnippet:fix/61489 -> nodejs:main
Labels     c++, semver-minor, lib / src, author ready, commit-queue-squash
Commits    34
 - net: add setTOS and getTOS to Socket
 - added doc
 - fixed some lint issues
 - already complete with validation and platform specific tests
 - added: REPLACEME
 - common.mustCall used
 - undo: unrelated header was removed irrelevantly
 - fix: resolve windows compilation and linter issues
 - rollback to tcp only
 - fix: ensure getTOS returns numeric default when handle lacks getTOS
 - fix: handle setTOS errors in afterConnect and use options.tos
 - fix: capture errno immediately after getsockopt failures
 - fix: use correct length type for Windows getsockopt and fix DSCP mask…
 - fix: validate options.tos in constructor
 - fix: use validateInt32 for options.tos and standardize GetTOS error
 - fix: remove unused errno_val in TCPWrap::GetTOS POSIX path
 - test: add boundary value assertions for TOS
 - test: add pre-connect TOS caching test
 - doc: add notes for setTOS and getTOS about pre-connect caching and OS…
 - fix: import UV_EBADF and remove duplicate mask declaration
 - fix: update TOS cache when handle lacks setTOS
 - doc: clarify pre-connect TOS test comment
 - refined: comments
 - doc: remove prohibited 'Note that' phrases
 - fix: reorder includes for Windows compatibility and add missing POSIX…
 - fix: resolve windows header order and doc lint errors
 - feat: rename setTOS/getTOS to setTypeOfService/getTypeOfService for A…
 - fix: update internal handle calls to use new TypeOfService method names
 - win vs2022 ci fix
 - added: todo for libuv api
 - fixed:win vs2022 lint ci
 - feat: rename C++ methods from SetTOS/GetTOS to SetTypeOfService/GetTy…
 - docs: update net.md for typeOfService option and fix lib/net.js const…
 - Apply suggestions from code review
Committers 2
 - Amol Yadav <amyssnipet@yahoo.com>
 - GitHub <noreply@github.com>
PR-URL: https://github.com/nodejs/node/pull/61503
Fixes: https://github.com/nodejs/node/issues/61489
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/61503
Fixes: https://github.com/nodejs/node/issues/61489
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
--------------------------------------------------------------------------------
   ℹ  This PR was created on Sat, 24 Jan 2026 11:11:33 GMT
   ✔  Approvals: 3
   ✔  - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/61503#pullrequestreview-3736689951
   ✔  - Robert Nagy (@ronag) (TSC): https://github.com/nodejs/node/pull/61503#pullrequestreview-3737494805
   ✔  - Anna Henningsen (@addaleax): https://github.com/nodejs/node/pull/61503#pullrequestreview-3711651185
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2026-01-31T02:05:35Z: https://ci.nodejs.org/job/node-test-pull-request/71128/
- Querying data for job/node-test-pull-request/71128/
✔  Build data downloaded
   ✔  Last Jenkins CI successful
   ⚠  PR author is a new contributor: @amyssnippet(amyssnipet@yahoo.com)
   ⚠  - commit d53c0157fc93 is authored by ronagy@icloud.com
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/21587645333

@ronag
Copy link
Member

ronag commented Feb 2, 2026

@aduh95 same failure as before " PR author is a new contributor: @amyssnippet(amyssnipet@yahoo.com)"

@amyssnippet
Copy link
Contributor Author

it looks like the commit queue is still failing because of mixed authorship and i am a new contributor. could anyone please manually land this PR as the bot seems unable to handle the squash in this scenario

@aduh95 aduh95 merged commit 5212c07 into nodejs:main Feb 2, 2026
95 of 96 checks passed
@aduh95
Copy link
Contributor

aduh95 commented Feb 2, 2026

Landed in 5212c07

@amyssnippet
Copy link
Contributor Author

thanks every maintainer here to help me contribute to the nodejs community

aduh95 pushed a commit that referenced this pull request Feb 2, 2026
PR-URL: #61503
Fixes: #61489
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
aduh95 added a commit that referenced this pull request Feb 2, 2026
Notable changes:

async_hooks:
  * (SEMVER-MINOR) add `trackPromises` option to `createHook()` (Joyee Cheung) #61415
net:
  * (SEMVER-MINOR) add `setTOS` and `getTOS` to `Socket` (Amol Yadav) #61503
src:
  * (SEMVER-MINOR) add initial support for ESM in embedder API (Joyee Cheung) #61548
  * improve `TextEncoder` encode performance with `simdutf` (Mert Can Altin) #61496
stream:
  * (SEMVER-MINOR) add `bytes()` method to `node:stream/consumers` (wantaek) #60426
test_runner:
  * (SEMVER-MINOR) add `env` option to `run` function (Ethan Arrowood) #61367
url:
  * update Ada to v3.4.2 and support Unicode 17 (Yagiz Nizipli) #61593

PR-URL: #61635
aduh95 added a commit that referenced this pull request Feb 2, 2026
Notable changes:

async_hooks:
  * (SEMVER-MINOR) add `trackPromises` option to `createHook()` (Joyee Cheung) #61415
net:
  * (SEMVER-MINOR) add `setTOS` and `getTOS` to `Socket` (Amol Yadav) #61503
src:
  * (SEMVER-MINOR) add initial support for ESM in embedder API (Joyee Cheung) #61548
  * improve `TextEncoder` encode performance with `simdutf` (Mert Can Altin) #61496
stream:
  * (SEMVER-MINOR) add `bytes()` method to `node:stream/consumers` (wantaek) #60426
test_runner:
  * (SEMVER-MINOR) add `env` option to `run` function (Ethan Arrowood) #61367
url:
  * update Ada to v3.4.2 and support Unicode 17 (Yagiz Nizipli) #61593

PR-URL: #61635
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-failed An error occurred while landing this pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. lib / src Issues and PRs related to general changes in the lib or src directory. 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.

socket.setTOS

10 participants