diff --git a/ext/node/polyfills/_tls_wrap.ts b/ext/node/polyfills/_tls_wrap.ts index 8f6f6ddc3b..e36fc637e7 100644 --- a/ext/node/polyfills/_tls_wrap.ts +++ b/ext/node/polyfills/_tls_wrap.ts @@ -151,13 +151,6 @@ export class TLSSocket extends net.Socket { // Patches `afterConnect` hook to replace TCP conn with TLS conn const afterConnect = handle.afterConnect; handle.afterConnect = async (req: any, status: number) => { - if (tlssock._isNpmAgent) { - // skips the TLS handshake for @npmcli/agent as it's handled by - // onSocket handler of ClientRequest object. - tlssock.emit("secure"); - tlssock.removeListener("end", onConnectEnd); - return afterConnect.call(handle, req, status); - } try { const conn = await Deno.startTls(handle[kStreamBaseField], options); try { diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts index ef1a090f03..a97c9e60ec 100644 --- a/ext/node/polyfills/http.ts +++ b/ext/node/polyfills/http.ts @@ -451,7 +451,7 @@ class ClientRequest extends OutgoingMessage { try { const parsedUrl = new URL(url); let baseConnRid = this.socket.rid; - if (this._encrypted) { + if (this._encrypted && !this.socket.authorized) { [baseConnRid] = op_tls_start({ rid: this.socket.rid, hostname: parsedUrl.hostname, diff --git a/ext/node/polyfills/internal_binding/tcp_wrap.ts b/ext/node/polyfills/internal_binding/tcp_wrap.ts index bb4b6d644a..96b4b0fd24 100644 --- a/ext/node/polyfills/internal_binding/tcp_wrap.ts +++ b/ext/node/polyfills/internal_binding/tcp_wrap.ts @@ -87,7 +87,6 @@ export enum constants { } export class TCP extends ConnectionWrap { - rid: number; [ownerSymbol]: unknown = null; override reading = false; @@ -259,6 +258,10 @@ export class TCP extends ConnectionWrap { } } + get rid() { + return this[kStreamBaseField][internalRidSymbol]; + } + /** * Populates the provided object with local address entries. * @param sockname An object to add the local address entries to. @@ -386,7 +389,6 @@ export class TCP extends ConnectionWrap { this.#address = req.localAddress = localAddr.hostname; this.#port = req.localPort = localAddr.port; this[kStreamBaseField] = conn; - this.rid = conn[internalRidSymbol]; try { this.afterConnect(req, 0);