diff --git a/src/node/heart.ts b/src/node/heart.ts index eed070e4e..1eada79b3 100644 --- a/src/node/heart.ts +++ b/src/node/heart.ts @@ -45,4 +45,13 @@ export class Heart { }) }, this.heartbeatInterval) } + + /** + * Call to clear any heartbeatTimer for shutdown. + */ + public dispose(): void { + if (typeof this.heartbeatTimer !== "undefined") { + clearTimeout(this.heartbeatTimer) + } + } } diff --git a/src/node/routes/index.ts b/src/node/routes/index.ts index 4688d6a2e..006543679 100644 --- a/src/node/routes/index.ts +++ b/src/node/routes/index.ts @@ -55,6 +55,9 @@ export const register = async ( }) }) }) + server.on("close", () => { + heart.dispose() + }) app.disable("x-powered-by") wsApp.disable("x-powered-by") diff --git a/test/integration.ts b/test/integration.ts index 6a321cae0..f829fe5de 100644 --- a/test/integration.ts +++ b/test/integration.ts @@ -8,6 +8,8 @@ export async function setup( argv: string[], configFile?: string, ): Promise<[express.Application, express.Application, httpserver.HttpServer, DefaultedArgs]> { + argv = ["--bind-addr=localhost:0", ...argv] + const cliArgs = parse(argv) const configArgs = parseConfigFile(configFile || "", "test/integration.ts") const args = await setDefaults(cliArgs, configArgs)