Skip to content

net: throw on multiple listen calls - #64871

Open
mcollina wants to merge 1 commit into
nodejs:mainfrom
mcollina:fix-net-multiple-listen
Open

net: throw on multiple listen calls#64871
mcollina wants to merge 1 commit into
nodejs:mainfrom
mcollina:fix-net-multiple-listen

Conversation

@mcollina

@mcollina mcollina commented Jul 31, 2026

Copy link
Copy Markdown
Member

Fixes #53204

Server.listen() could accept a second listen call while the first listen was still pending, allowing the later request to replace the earlier one. Track pending listen state and throw ERR_SERVER_ALREADY_LISTEN consistently.

The state is cleared on close, listen errors, handle transfer, and pipe permission failures.

@nodejs-github-bot

Copy link
Copy Markdown
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 31, 2026
@mcollina
mcollina requested review from Ethan-Arrowood and guybedford and removed request for guybedford July 31, 2026 11:58
@mcollina mcollina added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jul 31, 2026
@pimterry pimterry added request-ci Add this label to start a Jenkins CI on a PR. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Jul 31, 2026
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.15%. Comparing base (29d183d) to head (b04599c).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
lib/net.js 92.30% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #64871   +/-   ##
=======================================
  Coverage   90.15%   90.15%           
=======================================
  Files         746      746           
  Lines      242764   242775   +11     
  Branches    45741    45770   +29     
=======================================
+ Hits       218857   218883   +26     
+ Misses      15418    15368   -50     
- Partials     8489     8524   +35     
Files with missing lines Coverage Δ
lib/net.js 94.50% <92.30%> (-0.02%) ⬇️

... and 45 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

The registration order of http server listen depends on the Node.js version

4 participants