Skip to content

Conversation

@amyssnippet
Copy link

@amyssnippet amyssnippet commented Jan 24, 2026

this PR implements socket.setTOS(tos) and socket.getTOS() 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
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?

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

@amyssnippet
Copy link
Author

i checked the failing console logs of the ci failures, and thats totally flaky, kindly consider running the ci tests of github actions, and lets moove forward merging. Thank You!

@juanarbol
Copy link
Member

i checked the failing console logs of the ci failures, and thats totally flaky, kindly consider running the ci tests of github actions, and lets moove forward merging. Thank You!

We can't, let me re-trigger the CI

@nodejs-github-bot
Copy link
Collaborator

@amyssnippet
Copy link
Author

We can't, let me re-trigger the CI

but its all flaky, totally unrelated to my changes

@juanarbol
Copy link
Member

totally unrelated to my changes

I know, but we can't land when CI is not happy. No worries, your changes will land soon-ish :)

@amyssnippet
Copy link
Author

@juanarbol i guess its due to overhead use of the jenkins ci system. you can check each and every logs i have cited them here. its not my code fault its systems fault.

Failures:

  1. [Finished Build : #21908 of Job : node-test-commit-arm-debug with status : FAILURE at 11:44:37](https://ci.nodejs.org/job/node-test-commit-arm-debug/21908/nodes=ubuntu2404_debug-arm64/console) - reason No space left on device
image
  1. [Finished Build : #61939 of Job : node-test-commit-arm with status : FAILURE at 12:01:39](https://ci.nodejs.org/job/node-test-commit-arm/61939/nodes=ubuntu2404-arm64/console) - same reason no space left on device
image

even unstable build failures are due to the system cant run programs like git

image

@amyssnippet amyssnippet requested a review from ronag January 29, 2026 17:47
@nodejs-github-bot
Copy link
Collaborator

@amyssnippet
Copy link
Author

amyssnippet commented Jan 30, 2026

Warning

one ci is freezed, not even initiating. https://ci.nodejs.org/job/node-test-commit-arm-debug/21909/console

@ronag @mcollina @juanarbol @anonrig kindly check on this

@nodejs-github-bot
Copy link
Collaborator

@amyssnippet
Copy link
Author

Now @juanarbol ??

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

@mcollina mcollina added commit-queue Add this label to land a pull request using GitHub Actions. and removed needs-ci PRs that need a full CI run. labels Jan 30, 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 30, 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
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-30T06:34:48Z: 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/21534816018

@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. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. 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
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?? @ronag commited and he is member too

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

9 participants