diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2023-07-25 15:26:18 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-25 06:26:18 +0000 |
commit | 3d3590063954dd30c1ebea02aad136878eeee04e (patch) | |
tree | 6bc5fd53d4aa4c0d1d88a715f5e2a019fc9bd64f /ext | |
parent | e311e46a8f80491bc0ab4bc5dfce55d78bdb7187 (diff) |
fix(ext/net): fix string port number handling in listen (#19921)
While string `port` is not allowed in typing, it seems we used to
support that and now it's broken. ref:
https://github.com/denoland/deno/issues/10064#issuecomment-1637427260
This PR restores the support of string port number in `listen` and
`listenTls`
Diffstat (limited to 'ext')
-rw-r--r-- | ext/net/01_net.js | 3 | ||||
-rw-r--r-- | ext/net/02_tls.js | 4 |
2 files changed, 4 insertions, 3 deletions
diff --git a/ext/net/01_net.js b/ext/net/01_net.js index e8ce3a300..9cdcdb78c 100644 --- a/ext/net/01_net.js +++ b/ext/net/01_net.js @@ -15,6 +15,7 @@ const { ArrayPrototypeForEach, ArrayPrototypePush, Error, + Number, ObjectPrototypeIsPrototypeOf, PromiseResolve, SymbolAsyncIterator, @@ -420,7 +421,7 @@ function listen(args) { case "tcp": { const { 0: rid, 1: addr } = ops.op_net_listen_tcp({ hostname: args.hostname ?? "0.0.0.0", - port: args.port, + port: Number(args.port), }, args.reusePort); addr.transport = "tcp"; return new Listener(rid, addr); diff --git a/ext/net/02_tls.js b/ext/net/02_tls.js index a40972e34..4be2f08e0 100644 --- a/ext/net/02_tls.js +++ b/ext/net/02_tls.js @@ -4,7 +4,7 @@ const core = globalThis.Deno.core; const ops = core.ops; import { Conn, Listener } from "ext:deno_net/01_net.js"; const primordials = globalThis.__bootstrap.primordials; -const { TypeError } = primordials; +const { Number, TypeError } = primordials; function opStartTls(args) { return core.opAsync("op_tls_start", args); @@ -70,7 +70,7 @@ function listenTls({ throw new TypeError(`Unsupported transport: '${transport}'`); } const { 0: rid, 1: localAddr } = ops.op_net_listen_tls( - { hostname, port }, + { hostname, port: Number(port) }, { cert, certFile, key, keyFile, alpnProtocols, reusePort }, ); return new TlsListener(rid, localAddr); |