deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

node: net servers are swallowing errors and hanging the process

Open cjihrig opened this issue 2 years ago • 1 comments

Describe the bug If an exception is thrown from the handler of a running server, the process hangs and no error is reported. If the server is closed prior to throwing the exception, the process terminates, but the error is not displayed.

Steps to Reproduce Run the following script. The server.close() call can optionally be uncommented.

import net from "./node/net.ts";

const server = net.createServer((socket) => {
  // server.close();
  throw new Error("bye");
}).listen(0, "127.0.0.1", () => {
  const client = net.createConnection(server.address().port, "127.0.0.1")

  client.on("connect", () => {
    client.end();
  });
});

Expected behavior The process should exit with a stack trace.

Environment

  • OS: macOS
  • deno version: 1.25.0
  • std version: 0.153.0

cjihrig avatar Sep 01 '22 20:09 cjihrig

Maybe related: https://github.com/denoland/deno/issues/15869

lucacasonato avatar Sep 12 '22 14:09 lucacasonato