Skip to content

tls: destroy socket when newSession listener throws - #67605

Open
ShogunPanda wants to merge 1 commit into
nodejs:mainfrom
ShogunPanda:tls-destroy-socket-on-newsession-error
Open

ShogunPanda wants to merge 1 commit into
nodejs:mainfrom
ShogunPanda:tls-destroy-socket-on-newsession-error

Conversation

@ShogunPanda

Copy link
Copy Markdown
Contributor

When a newSession listener on a tls.Server throws, the guard in onnewsession re-emits the exception as an 'error' event on the server instead of destroying the socket, unlike the other handshake callback guards (SNICallback, resumeSession, OCSPRequest). A server without an 'error' listener then rethrows it from inside the callback.

The exception is now routed to socket.destroy(err). The regression test no longer registers a server 'error' listener, and checks that the server-side socket is destroyed with the original error.

AI-assisted work. All changes reviewed by a human.

Route exceptions thrown by `newSession` listeners to `socket.destroy(err)`,
like the other handshake callback guards, instead of re-emitting them on
the server. Update the regression test to run without a server `error`
listener.

Assisted-By: OpenAI GPT-5.6 Sol <openai/gpt-5.6-sol>
Signed-off-by: Paolo Insogna <paolo@cowtech.it>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. tls Issues and PRs related to the tls subsystem. labels Nov 19, 2026
@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.71%. Comparing base (cdd0687) to head (5584c8d).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67605      +/-   ##
==========================================
- Coverage   90.73%   90.71%   -0.02%     
==========================================
  Files         801      801              
  Lines      280794   280809      +15     
  Branches    54202    54211       +9     
==========================================
- Hits       254771   254733      -38     
- Misses      16202    16252      +50     
- Partials     9821     9824       +3     
Files with missing lines Coverage Δ
lib/internal/tls/wrap.js 95.80% <100.00%> (ø)

... and 37 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. tls Issues and PRs related to the tls subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants