Skip to content

fix(tls): preserve servernames set before connecting - #197

Merged
steipete merged 3 commits into
mainfrom
fix/tls-preconnect-sni
Oct 24, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/tls-preconnect-sni

Conversation

@steipete

@steipete steipete commented Oct 24, 2026 •

Copy link
Copy Markdown

A bare tls.TLSSocket with setServername("set.before.connect") called before connect() sent no SNI. The server received false, while Node.js 26 and stock Bun nightly received the explicit name. Both direct dialing and autoSelectFamily were affected.

net.Socket.connect() replaces the public servername field with its options. TLS already records pending names in a private socket field, but the fork adapter stopped reading it. Read that field first, preserving an explicitly cleared empty name and the existing omission behavior for absent/null names and falsy names with an explicit secure context. Connection-host and shared-context names remain excluded.

The October 16 sync (2c9435668e6, #177) reapplied #171 while dropping this private-field lookup from its upstream parent. The current oven-sh#45260 patch already retains the lookup. The fix stays in the Node TLS adapter; native transport ownership is unaffected.

The portable fixture now covers pending-name replacement, empty names, family selection, and falsy explicit-context controls. Promote the two existing pre-connect SNI expected failures to ordinary tests with their assertions unchanged. Update the Node compatibility note and changelog.

Validation on head c8e312cdd8380d8951726a7138000367bb6ca2af:

Check Result
Node.js 26.12.1 portable fixture 40 pass
Published fork ef37c31de3, promoted pre-connect tests 2 fail, server receives no SNI
Stock nightly, promoted pre-connect tests 2 pass
Native Linux x64 CI 45 selected files pass
Native macOS arm64 CI 46 selected files pass
Downloaded macOS CI executable All 5 wire-level repro cases match Node; 40-case fixture passes; both promoted regressions pass
Injected HTTP/TLS transport checks on that executable 16 pass, 0 fail
Canary formatter, JavaScript lint, Codex P2 review Clean

Native CI and executable artifacts. Both native selections include the full hostname-verification file, node-tls-connect, TLS server, wrapped-socket, and upgrade suites. The downloaded executable's synthetic merge tree exactly matches the PR head tree.

Read the pending socket servername when preparing TLS options, preserving explicit empty names while continuing to suppress implicit host SNI. Add Node-compatible server-observed direct and address-family-selection regressions.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T07:10:09.582516Z 4f5b02e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@autofix-troubleshooter

Copy link
Copy Markdown

Hi! I'm the autofix logoautofix.ci troubleshooter bot.

It looks like you correctly set up a CI job that uses the autofix.ci GitHub Action, but the autofix.ci GitHub App has not been installed for this repository. This means that autofix.ci unfortunately does not have the permissions to fix this pull request. If you are the repository owner, please install the app and then restart the CI workflow! 😃

Keep the existing public-name fallback while prioritizing pending setServername state. Cover false and zero names with explicit contexts, and apply the CI import ordering.
Promote the two existing pre-connect SNI tests now that pending names reach the handshake, and remove their obsolete inherited-gap comments. Their assertions are unchanged.
@steipete
steipete merged commit 91199eb into main Oct 24, 2026
5 checks passed
@steipete
steipete deleted the fix/tls-preconnect-sni branch October 24, 2026 08:05
steipete added a commit that referenced this pull request Oct 24, 2026
…al design (#198)

This reverts f45fff0 (#195), resolving
overlap with #196 without restoring its Error.cause serialization changes.

The fixed small-payload Worker postMessage gate measured a median paired
ratio of 1.053 against a maximum 1.03, with 9 of 10 pairs slower. Remove the
per-container bookkeeping pending a design that charges only large-Buffer
paths. Preserve the #197 pre-connect SNI fix and the historical #195
changelog entry, with a new backout note.
steipete added a commit that referenced this pull request Oct 24, 2026
…al design (#198)

This reverts f45fff0 (#195), resolving
overlap with #196 without restoring its Error.cause serialization changes.

The fixed small-payload Worker postMessage gate measured a median paired
ratio of 1.053 against a maximum 1.03, with 9 of 10 pairs slower. Remove the
per-container bookkeeping pending a design that charges only large-Buffer
paths. Preserve the #197 pre-connect SNI fix and the historical #195
changelog entry, with a new backout note.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants