Skip to content

node: tls: accept ALPNProtocols for undici compatibility#6546

Open
KevinSailema wants to merge 2 commits intocloudflare:mainfrom
KevinSailema:fix/workerd-6527-alpnprotocols
Open

node: tls: accept ALPNProtocols for undici compatibility#6546
KevinSailema wants to merge 2 commits intocloudflare:mainfrom
KevinSailema:fix/workerd-6527-alpnprotocols

Conversation

@KevinSailema
Copy link
Copy Markdown

Fixes #6527

This change fixes a Node.js compatibility issue where TLS connections failed with:
The options.ALPNProtocols option is not implemented

In practice, this was breaking @elastic/elasticsearch usage on Workers because Undici passes ALPNProtocols by default on HTTPS connections.

Root cause

The TLS compatibility layer in internal_tls_wrap.ts explicitly rejected options.ALPNProtocols, even though this option is commonly set by upstream clients and connectors.

What changed

  • Accept ALPNProtocols in TLSSocket options instead of throwing.
  • Keep Node-like input validation by normalizing ALPNProtocols via convertALPNProtocols.
  • Add regression coverage in tls-nodejs-test.js:
  • handshake succeeds when ALPNProtocols is provided
  • invalid ALPN protocol length still throws ERR_OUT_OF_RANGE

Why this is safe

  • This PR removes an unnecessary compatibility rejection, but does not claim full ALPN feature exposure through the public sockets API.
  • Existing validation behavior is preserved.
  • Scope is intentionally minimal and focused on ecosystem compatibility.

Validation

  • npx -y @bazel/bazelisk test //src/workerd/api/node/tests:tls-nodejs-test@ --test_output=errors
  • npx -y @bazel/bazelisk test //src/workerd/api/node/tests:tls-nodejs-test@all-compat-flags //src/workerd/api/node/tests:tls-nodejs-test@all-autogates --test_output=errors

@KevinSailema KevinSailema requested review from a team as code owners April 10, 2026 00:15
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 10, 2026


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@KevinSailema KevinSailema force-pushed the fix/workerd-6527-alpnprotocols branch from 37933d6 to d001109 Compare April 10, 2026 00:22
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.

ElasticSearch Support in Cloudflare Workers

1 participant