diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts index 08b3ca80c0..221ecee605 100644 --- a/cli/dts/lib.deno.unstable.d.ts +++ b/cli/dts/lib.deno.unstable.d.ts @@ -1049,7 +1049,10 @@ declare namespace Deno { * * Requires `allow-net` permission for "tcp" and `allow-read` for "unix". */ export function connect( - options: ConnectOptions | UnixConnectOptions, + options: ConnectOptions, + ): Promise; + export function connect( + options: UnixConnectOptions, ): Promise; export interface ConnectTlsOptions { @@ -1066,21 +1069,6 @@ declare namespace Deno { alpnProtocols?: string[]; } - export interface Conn { - /** - * **UNSTABLE**: new API, see https://github.com/denoland/deno/issues/13617. - * - * Enable/disable the use of Nagle's algorithm. Defaults to true. - */ - setNoDelay(nodelay?: boolean): void; - /** - * **UNSTABLE**: new API, see https://github.com/denoland/deno/issues/13617. - * - * Enable/disable keep-alive functionality. - */ - setKeepAlive(keepalive?: boolean): void; - } - export interface TlsHandshakeInfo { /** **UNSTABLE**: new API, yet to be vetted. * diff --git a/cli/tests/unit/tls_test.ts b/cli/tests/unit/tls_test.ts index 26a1668013..07ffcd487a 100644 --- a/cli/tests/unit/tls_test.ts +++ b/cli/tests/unit/tls_test.ts @@ -1075,7 +1075,7 @@ Deno.test( const port = 587; const encoder = new TextEncoder(); - let conn = await Deno.connect({ + const conn = await Deno.connect({ hostname, port, }); @@ -1102,9 +1102,9 @@ Deno.test( // Received the message that the server is ready to establish TLS assertEquals(line, "220 2.0.0 Ready to start TLS"); - conn = await Deno.startTls(conn, { hostname }); - writer = new BufWriter(conn); - reader = new TextProtoReader(new BufReader(conn)); + const tlsConn = await Deno.startTls(conn, { hostname }); + writer = new BufWriter(tlsConn); + reader = new TextProtoReader(new BufReader(tlsConn)); // After that use TLS communication again await writer.write(encoder.encode(`EHLO ${hostname}\r\n`)); @@ -1115,7 +1115,7 @@ Deno.test( if (line.startsWith("250 ")) break; } - conn.close(); + tlsConn.close(); }, ); diff --git a/cli/tsc.rs b/cli/tsc.rs index 9500aae74d..bff2f3404d 100644 --- a/cli/tsc.rs +++ b/cli/tsc.rs @@ -1148,6 +1148,7 @@ mod tests { let actual = test_exec(&specifier) .await .expect("exec should not have errored"); + eprintln!("diagnostics {:#?}", actual.diagnostics); assert!(actual.diagnostics.is_empty()); assert!(actual.emitted_files.is_empty()); assert!(actual.maybe_tsbuildinfo.is_some()); @@ -1160,6 +1161,7 @@ mod tests { let actual = test_exec(&specifier) .await .expect("exec should not have errored"); + eprintln!("diagnostics {:#?}", actual.diagnostics); assert!(actual.diagnostics.is_empty()); assert!(actual.emitted_files.is_empty()); assert!(actual.maybe_tsbuildinfo.is_some()); @@ -1172,6 +1174,7 @@ mod tests { let actual = test_exec(&specifier) .await .expect("exec should not have errored"); + eprintln!("diagnostics {:#?}", actual.diagnostics); assert!(actual.diagnostics.is_empty()); } } diff --git a/ext/net/01_net.js b/ext/net/01_net.js index 2970dd8179..8c17942dae 100644 --- a/ext/net/01_net.js +++ b/ext/net/01_net.js @@ -163,14 +163,6 @@ return shutdown(this.rid); } - setNoDelay(nodelay = true) { - return core.opSync("op_set_nodelay", this.rid, nodelay); - } - - setKeepAlive(keepalive = true) { - return core.opSync("op_set_keepalive", this.rid, keepalive); - } - get readable() { if (this.#readable === undefined) { this.#readable = readableStreamForRid(this.rid); @@ -186,6 +178,16 @@ } } + class TcpConn extends Conn { + setNoDelay(nodelay = true) { + return core.opSync("op_set_nodelay", this.rid, nodelay); + } + + setKeepAlive(keepalive = true) { + return core.opSync("op_set_keepalive", this.rid, keepalive); + } + } + class Listener { #rid = 0; #addr = null; @@ -205,6 +207,9 @@ async accept() { const res = await opAccept(this.rid, this.addr.transport); + if (this.addr.transport == "tcp") { + return new TcpConn(res.rid, res.remoteAddr, res.localAddr); + } return new Conn(res.rid, res.remoteAddr, res.localAddr); } @@ -318,12 +323,13 @@ }); } - return new Conn(res.rid, res.remoteAddr, res.localAddr); + return new TcpConn(res.rid, res.remoteAddr, res.localAddr); } window.__bootstrap.net = { connect, Conn, + TcpConn, opConnect, listen, opListen, diff --git a/ext/net/lib.deno_net.d.ts b/ext/net/lib.deno_net.d.ts index 0384520555..ab779a1ff2 100644 --- a/ext/net/lib.deno_net.d.ts +++ b/ext/net/lib.deno_net.d.ts @@ -143,7 +143,22 @@ declare namespace Deno { * ``` * * Requires `allow-net` permission for "tcp". */ - export function connect(options: ConnectOptions): Promise; + export function connect(options: ConnectOptions): Promise; + + export interface TcpConn extends Conn { + /** + * **UNSTABLE**: new API, see https://github.com/denoland/deno/issues/13617. + * + * Enable/disable the use of Nagle's algorithm. Defaults to true. + */ + setNoDelay(nodelay?: boolean): void; + /** + * **UNSTABLE**: new API, see https://github.com/denoland/deno/issues/13617. + * + * Enable/disable keep-alive functionality. + */ + setKeepAlive(keepalive?: boolean): void; + } export interface ConnectTlsOptions { /** The port to connect to. */