diff options
author | Inteon <42113979+inteon@users.noreply.github.com> | 2021-04-08 18:04:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-08 18:04:02 +0200 |
commit | d050b491b10fe37b4461b37c56028a14c8674c95 (patch) | |
tree | 47aa768f3027dff90ffd1aacdd267274610bf441 /cli/bench/deno_tcp.ts | |
parent | c4b21fbff119a8ce006391d8fb7586877759bcef (diff) |
fix(core): error handling in examples (#9867)
Diffstat (limited to 'cli/bench/deno_tcp.ts')
-rw-r--r-- | cli/bench/deno_tcp.ts | 15 |
1 files changed, 9 insertions, 6 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); |