Skip to content

Commit

Permalink
FUTURE(ext/net): remove `Deno.(Conn|TlsConn|Listener|TlsListener|Unix…
Browse files Browse the repository at this point in the history
…Conn).prototype.rid` (#23219)

Towards #23089

---------

Signed-off-by: Asher Gomez <[email protected]>
  • Loading branch information
iuioiua authored and satyarohith committed Apr 11, 2024
1 parent f05b029 commit 255411e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ext/net/01_net.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ class Conn {
#writable;

constructor(rid, remoteAddr, localAddr) {
if (internals.future) {
ObjectDefineProperty(this, "rid", {
enumerable: false,
value: undefined,
});
}
ObjectDefineProperty(this, internalRidSymbol, {
enumerable: false,
value: rid,
Expand Down Expand Up @@ -260,6 +266,12 @@ class Listener {
#promise = null;

constructor(rid, addr) {
if (internals.future) {
ObjectDefineProperty(this, "rid", {
enumerable: false,
value: undefined,
});
}
ObjectDefineProperty(this, internalRidSymbol, {
enumerable: false,
value: rid,
Expand Down
41 changes: 41 additions & 0 deletions tests/specs/future/runtime_api/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,47 @@ console.log("Deno.writeAllSync is", Deno.writeAllSync);
console.log("Deno.write is", Deno.write);
console.log("Deno.writeSync is", Deno.writeSync);

// TCP
// Since these tests may run in parallel, ensure this port is unique to this file
const tcpPort = 4509;
const tcpListener = Deno.listen({ port: tcpPort });
console.log("Deno.Listener.prototype.rid is", tcpListener.rid);

const tcpConn = await Deno.connect({ port: tcpPort });
console.log("Deno.Conn.prototype.rid is", tcpConn.rid);

tcpConn.close();
tcpListener.close();

// Unix
if (Deno.build.os === "windows") {
console.log("Deno.UnixConn.prototype.rid is undefined");
} else {
const socketPath = "./test.sock";
const unixListener = Deno.listen({ transport: "unix", path: socketPath });

const unixConn = await Deno.connect({ transport: "unix", path: socketPath });
console.log("Deno.UnixConn.prototype.rid is", unixConn.rid);

unixConn.close();
unixListener.close();
Deno.removeSync(socketPath);
}

// TLS
// Since these tests may run in parallel, ensure this port is unique to this file
const tlsPort = 4510;
const cert = Deno.readTextFileSync("../../../testdata/tls/localhost.crt");
const key = Deno.readTextFileSync("../../../testdata/tls/localhost.key");
const tlsListener = Deno.listenTls({ port: tlsPort, cert, key });
console.log("Deno.TlsListener.prototype.rid is", tlsListener.rid);

const tlsConn = await Deno.connectTls({ port: tlsPort });
console.log("Deno.TlsConn.prototype.rid is", tlsConn.rid);

tlsConn.close();
tlsListener.close();

const watcher = Deno.watchFs(".");
console.log("Deno.FsWatcher.prototype.rid is", watcher.rid);
watcher.close();
Expand Down
5 changes: 5 additions & 0 deletions tests/specs/future/runtime_api/main.out
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,10 @@ Deno.writeAll is undefined
Deno.writeAllSync is undefined
Deno.write is undefined
Deno.writeSync is undefined
Deno.Listener.prototype.rid is undefined
Deno.Conn.prototype.rid is undefined
Deno.UnixConn.prototype.rid is undefined
Deno.TlsListener.prototype.rid is undefined
Deno.TlsConn.prototype.rid is undefined
Deno.FsWatcher.prototype.rid is undefined
Deno.FsFile constructor is illegal

0 comments on commit 255411e

Please sign in to comment.