diff --git a/ext/net/01_net.js b/ext/net/01_net.js index ffae6c56f6..73d8bad49c 100644 --- a/ext/net/01_net.js +++ b/ext/net/01_net.js @@ -1,6 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -import { core, primordials } from "ext:core/mod.js"; +import { core, internals, primordials } from "ext:core/mod.js"; const { BadResourcePrototype, InterruptedPrototype, @@ -216,6 +216,11 @@ class Listener { } get rid() { + internals.warnOnDeprecatedApi( + "Deno.Listener.rid", + new Error().stack, + "Use `Deno.Listener` instance methods instead.", + ); return this.#rid; } @@ -227,10 +232,10 @@ class Listener { let promise; switch (this.addr.transport) { case "tcp": - promise = op_net_accept_tcp(this.rid); + promise = op_net_accept_tcp(this.#rid); break; case "unix": - promise = op_net_accept_unix(this.rid); + promise = op_net_accept_unix(this.#rid); break; default: throw new Error(`Unsupported transport: ${this.addr.transport}`); @@ -276,7 +281,7 @@ class Listener { } close() { - core.close(this.rid); + core.close(this.#rid); } [SymbolDispose]() { diff --git a/ext/net/lib.deno_net.d.ts b/ext/net/lib.deno_net.d.ts index 2392c1ff46..a7ed95baea 100644 --- a/ext/net/lib.deno_net.d.ts +++ b/ext/net/lib.deno_net.d.ts @@ -35,7 +35,12 @@ declare namespace Deno { /** Return the address of the `Listener`. */ readonly addr: Addr; - /** Return the rid of the `Listener`. */ + /** + * Return the rid of the `Listener`. + * + * @deprecated Use {@linkcode Deno.Listener} instance methods instead. + * {@linkcode Deno.Listener.rid} will be removed in Deno 2.0. + */ readonly rid: number; [Symbol.asyncIterator](): AsyncIterableIterator;