Skip to content

fix(ext/node): remove kUseNativeWrap on TLS TCP handles to fix HTTPS regression#33251

Open
rawkakani wants to merge 1 commit intodenoland:mainfrom
rawkakani:fix/tls-wrap-rid-regression
Open

fix(ext/node): remove kUseNativeWrap on TLS TCP handles to fix HTTPS regression#33251
rawkakani wants to merge 1 commit intodenoland:mainfrom
rawkakani:fix/tls-wrap-rid-regression

Conversation

@rawkakani
Copy link
Copy Markdown

@rawkakani rawkakani commented Apr 12, 2026

Summary

Removes handle[kUseNativeWrap] = true from TLSSocket._wrapHandle in _tls_wrap.js, fixing an HTTPS client regression introduced in v2.7.12.

AI Disclosure

This PR was written with assistance from Claude (Anthropic). This PR was fully authored with Claude Code (Anthropic). Claude performed the version bisection testing, identified the breaking commit by diffing v2.7.11 and v2.7.12, traced the root cause through the source code, wrote the fix, and drafted the commit message and PR description.

Problem

PR #33184 (3ec37cc7e012) added kUseNativeWrap = true on freshly created TCP handles inside _wrapHandle. This forces the handle into the #nativeConnect path which never populates kStreamBaseField.

When http.ts:_writeHeader later reads handle[kStreamBaseField][internalRidSymbol] to get the connection rid for op_node_http_request_with_conn, it crashes:

TypeError: Cannot read properties of undefined (reading 'Symbol(Deno.internal.rid)')
    at node:http:370:49
    at HttpsClientRequest._writeHeader (node:http:603:7)

This breaks all HTTPS client requests via Node compat — affects Playwright (#33229), @deno/sandbox, and any npm package using https.request().

Regression bisection

Version Status
2.7.0 ✅ Works
2.7.5 ✅ Works
2.7.11 ✅ Works
2.7.12 ❌ Broken

Fix

Remove the kUseNativeWrap = true assignment (1 line) so freshly created TCP handles use the legacy connect path that populates kStreamBaseField with a TcpConn carrying a valid rid.

The native TLSWrap still works — it just wraps a handle that went through the legacy connect path.

Reproduction

// Any HTTPS request via Node compat crashes on 2.7.12:
import https from "node:https";
https.get("https://example.com", (res) => console.log(res.statusCode));
// TypeError: Cannot read properties of undefined (reading 'Symbol(Deno.internal.rid)')

Test plan

The existing Node compat test suite for https and tls covers this path. A minimal test:

Deno.test("node:https GET request works", async () => {
  const https = await import("node:https");
  const status = await new Promise((resolve, reject) => {
    https.get("https://example.com", (res) => resolve(res.statusCode)).on("error", reject);
  });
  assertEquals(status, 200);
});

Fixes #33231
Fixes #33229

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 12, 2026

CLA assistant check
All committers have signed the CLA.

@rawkakani rawkakani force-pushed the fix/tls-wrap-rid-regression branch from 8a3671f to 53900b6 Compare April 12, 2026 14:50
…regression

The native wrap path introduced in denoland#33184 sets `kUseNativeWrap = true` on
freshly created TCP handles in `TLSSocket._wrapHandle`. This forces the
handle into `#nativeConnect` which never populates `kStreamBaseField`.

When `http.ts:_writeHeader` later reads
`handle[kStreamBaseField][internalRidSymbol]` to obtain the connection
rid for `op_node_http_request_with_conn`, it crashes:

    TypeError: Cannot read properties of undefined
      (reading 'Symbol(Deno.internal.rid)')

This breaks all HTTPS client requests via Node compat (Playwright,
@deno/sandbox, any npm package using https.request).

Regression bisected:
  - 2.7.11: works
  - 2.7.12: broken

Fix: remove the `kUseNativeWrap = true` assignment so freshly created
TCP handles use the legacy connect path that populates `kStreamBaseField`
with a `TcpConn` carrying a valid rid.

Fixes denoland#33231
Fixes denoland#33229
@rawkakani rawkakani force-pushed the fix/tls-wrap-rid-regression branch from 53900b6 to 4ffa0b4 Compare April 12, 2026 14:51
@bartlomieju
Copy link
Copy Markdown
Member

Thanks, but this needs a test. I have doubts that this actually fixes the problem

@rawkakani
Copy link
Copy Markdown
Author

Thanks, but this needs a test. I have doubts that this actually fixes the problem

understood, shall let the ai know 😅

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.

Playwright error after update to Deno 2.7.12 Regression: Launching Firefox with MS Playwright Times Out

3 participants