diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts
index b3ee0c4ee0..f2fc0cf3bf 100644
--- a/cli/tsc/dts/lib.deno.unstable.d.ts
+++ b/cli/tsc/dts/lib.deno.unstable.d.ts
@@ -876,8 +876,6 @@ declare namespace Deno {
* @category Fetch API
*/
export interface HttpClient extends Disposable {
- /** The resource ID associated with the client. */
- rid: number;
/** Close the HTTP client. */
close(): void;
}
diff --git a/ext/fetch/22_http_client.js b/ext/fetch/22_http_client.js
index bd838e6636..c1ddbd7c4f 100644
--- a/ext/fetch/22_http_client.js
+++ b/ext/fetch/22_http_client.js
@@ -10,11 +10,14 @@
///
///
-import { core } from "ext:core/mod.js";
+import { core, primordials } from "ext:core/mod.js";
import { SymbolDispose } from "ext:deno_web/00_infra.js";
import { op_fetch_custom_client } from "ext:core/ops";
+const { internalRidSymbol } = core;
+const { ObjectDefineProperty } = primordials;
+
/**
* @param {Deno.CreateHttpClientOptions} options
* @returns {HttpClient}
@@ -29,19 +32,25 @@ function createHttpClient(options) {
}
class HttpClient {
+ #rid;
+
/**
* @param {number} rid
*/
constructor(rid) {
- this.rid = rid;
+ ObjectDefineProperty(this, internalRidSymbol, {
+ enumerable: false,
+ value: rid,
+ });
+ this.#rid = rid;
}
close() {
- core.close(this.rid);
+ core.close(this.#rid);
}
[SymbolDispose]() {
- core.tryClose(this.rid);
+ core.tryClose(this.#rid);
}
}
const HttpClientPrototype = HttpClient.prototype;
diff --git a/ext/fetch/23_request.js b/ext/fetch/23_request.js
index 8ca92ca729..542bcb8bb2 100644
--- a/ext/fetch/23_request.js
+++ b/ext/fetch/23_request.js
@@ -9,7 +9,7 @@
///
///
-import { primordials } from "ext:core/mod.js";
+import { core, primordials } from "ext:core/mod.js";
const {
ArrayPrototypeMap,
ArrayPrototypeSlice,
@@ -45,6 +45,8 @@ import {
import { HttpClientPrototype } from "ext:deno_fetch/22_http_client.js";
import * as abortSignal from "ext:deno_web/03_abort_signal.js";
+const { internalRidSymbol } = core;
+
const _request = Symbol("request");
const _headers = Symbol("headers");
const _getHeaders = Symbol("get headers");
@@ -355,7 +357,7 @@ class Request {
"Argument 2",
);
}
- request.clientRid = init.client?.rid ?? null;
+ request.clientRid = init.client?.[internalRidSymbol] ?? null;
}
// 28.
diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts
index 0c6501d87d..28b7f15b2c 100644
--- a/ext/node/polyfills/http.ts
+++ b/ext/node/polyfills/http.ts
@@ -65,6 +65,8 @@ import { clearTimeout as webClearTimeout } from "ext:deno_web/02_timers.js";
import { resourceForReadableStream } from "ext:deno_web/06_streams.js";
import { TcpConn } from "ext:deno_net/01_net.js";
+const { internalRidSymbol } = core;
+
enum STATUS_CODES {
/** RFC 7231, 6.2.1 */
Continue = 100,
@@ -616,7 +618,7 @@ class ClientRequest extends OutgoingMessage {
this.method,
url,
headers,
- client.rid,
+ client[internalRidSymbol],
this._bodyWriteRid,
);
}
@@ -802,7 +804,7 @@ class ClientRequest extends OutgoingMessage {
}
this.destroyed = true;
- const rid = this._client?.rid;
+ const rid = this._client?.[internalRidSymbol];
if (rid) {
core.tryClose(rid);
}