From 09e844a153b48d7f15ccfa4da961c205800b6751 Mon Sep 17 00:00:00 2001 From: Peter Somogyvari Date: Tue, 20 Oct 2020 13:19:07 -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"); });