diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/bench/deno_tcp.ts | 15 | ||||
-rw-r--r-- | cli/bench/deno_tcp_proxy.ts | 14 | ||||
-rw-r--r-- | cli/bench/http.rs | 2 | ||||
-rw-r--r-- | cli/bench/node_tcp_promise.js | 25 | ||||
-rw-r--r-- | cli/tests/unit/dispatch_bin_test.ts | 26 |
5 files changed, 45 insertions, 37 deletions
diff --git a/cli/bench/deno_tcp.ts b/cli/bench/deno_tcp.ts index e6ee4e239..2216beab5 100644 --- a/cli/bench/deno_tcp.ts +++ b/cli/bench/deno_tcp.ts @@ -13,15 +13,18 @@ async function handle(conn: Deno.Conn): Promise<void> { const buffer = new Uint8Array(1024); try { while (true) { - const r = await conn.read(buffer); - if (r === null) { - break; - } + await conn.read(buffer); await conn.write(response); } - } finally { - conn.close(); + } catch (e) { + if ( + !(e instanceof Deno.errors.BrokenPipe) && + !(e instanceof Deno.errors.ConnectionReset) + ) { + throw e; + } } + conn.close(); } console.log("Listening on", addr); diff --git a/cli/bench/deno_tcp_proxy.ts b/cli/bench/deno_tcp_proxy.ts index 1a424cee5..bab8eac19 100644 --- a/cli/bench/deno_tcp_proxy.ts +++ b/cli/bench/deno_tcp_proxy.ts @@ -15,14 +15,16 @@ async function handle(conn: Deno.Conn): Promise<void> { }); try { await Promise.all([Deno.copy(conn, origin), Deno.copy(origin, conn)]); - } catch (err) { - if (err.message !== "read error" && err.message !== "write error") { - throw err; + } catch (e) { + if ( + !(e instanceof Deno.errors.BrokenPipe) && + !(e instanceof Deno.errors.ConnectionReset) + ) { + throw e; } - } finally { - conn.close(); - origin.close(); } + conn.close(); + origin.close(); } console.log(`Proxy listening on http://${addr}/`); diff --git a/cli/bench/http.rs b/cli/bench/http.rs index f954223a0..952f3f19b 100644 --- a/cli/bench/http.rs +++ b/cli/bench/http.rs @@ -107,6 +107,8 @@ fn run( println!("{}", wrk_cmd.join(" ")); let output = test_util::run_collect(wrk_cmd, None, None, None, true).0; + std::thread::sleep(Duration::from_secs(1)); // wait to capture failure. TODO racy. + println!("{}", output); assert!( server.try_wait()?.map_or(true, |s| s.success()), diff --git a/cli/bench/node_tcp_promise.js b/cli/bench/node_tcp_promise.js deleted file mode 100644 index 6f0b810e5..000000000 --- a/cli/bench/node_tcp_promise.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -// Note: this is a keep-alive server. -const { Server } = require("net"); -const port = process.argv[2] || "4544"; -console.log("port", port); - -const response = Buffer.from( - "HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nHello World\n", -); - -function write(socket, buffer) { - const p = new Promise((resolve, _) => { - socket.write(buffer, resolve); - }); - return Promise.resolve(p); -} - -Server(async (socket) => { - socket.on("error", (_) => { - socket.destroy(); - }); - for await (const _ of socket) { - await write(socket, response); - } -}).listen(port); diff --git a/cli/tests/unit/dispatch_bin_test.ts b/cli/tests/unit/dispatch_bin_test.ts index 83053461d..ca1864621 100644 --- a/cli/tests/unit/dispatch_bin_test.ts +++ b/cli/tests/unit/dispatch_bin_test.ts @@ -32,3 +32,29 @@ declare global { var core: any; // eslint-disable-line no-var } } + +unitTest(async function binOpsAsyncBadResource(): Promise<void> { + try { + const nonExistingRid = 9999; + await Deno.core.binOpAsync( + "op_read_async", + nonExistingRid, + new Uint8Array(0), + ); + } catch (e) { + if (!(e instanceof Deno.errors.BadResource)) { + throw e; + } + } +}); + +unitTest(function binOpsSyncBadResource(): void { + try { + const nonExistingRid = 9999; + Deno.core.binOpSync("op_read_sync", nonExistingRid, new Uint8Array(0)); + } catch (e) { + if (!(e instanceof Deno.errors.BadResource)) { + throw e; + } + } +}); |