From 934c2c2ca2cd9449bd7ad00b190d64929c4e7548 Mon Sep 17 00:00:00 2001 From: Peter Somogyvari Date: Mon, 26 Oct 2020 18:26:41 -0700 Subject: [PATCH] fix(common): servers.startOnPort() error handling Promise no longer hangs if error event is fired on the server object Fixes #317 Signed-off-by: Peter Somogyvari --- packages/cactus-common/src/main/typescript/servers.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/cactus-common/src/main/typescript/servers.ts b/packages/cactus-common/src/main/typescript/servers.ts index 2fa96778384..d93cc2853b0 100644 --- a/packages/cactus-common/src/main/typescript/servers.ts +++ b/packages/cactus-common/src/main/typescript/servers.ts @@ -96,6 +96,7 @@ export class Servers { const server: Server = await new Promise((resolve, reject) => { const aServer: Server = createServer(); aServer.once("listening", () => resolve(aServer)); + aServer.once("error", (err: Error) => reject(err)); aServer.listen(port, "localhost"); });