From 316ef063ac6987b3a6e8f501c38a3945a0b29de3 Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Fri, 21 Jul 2023 13:41:10 -0400 Subject: [PATCH] Heartbeat: implement in both live-reload servers (#6927) --- packages/remix-dev/devServer/liveReload.ts | 2 +- packages/remix-dev/devServer_unstable/socket.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/remix-dev/devServer/liveReload.ts b/packages/remix-dev/devServer/liveReload.ts index 3ac6de4b69e..79dfaae62de 100644 --- a/packages/remix-dev/devServer/liveReload.ts +++ b/packages/remix-dev/devServer/liveReload.ts @@ -76,7 +76,7 @@ export async function liveReload(config: RemixConfig) { } ); - const heartbeat = setInterval(broadcast, 60000, { type: "PING" }); + let heartbeat = setInterval(broadcast, 60000, { type: "PING" }); exitHook(() => clean(config)); return async () => { diff --git a/packages/remix-dev/devServer_unstable/socket.ts b/packages/remix-dev/devServer_unstable/socket.ts index 27c07f3df1f..62906c4f4da 100644 --- a/packages/remix-dev/devServer_unstable/socket.ts +++ b/packages/remix-dev/devServer_unstable/socket.ts @@ -37,5 +37,12 @@ export let serve = (server: HTTPServer) => { broadcast({ type: "HMR", assetsManifest, updates }); }; - return { log, reload, hmr, close: wss.close }; + let heartbeat = setInterval(broadcast, 60000, { type: "PING" }); + + let close = () => { + clearInterval(heartbeat); + return wss.close(); + }; + + return { log, reload, hmr, close }; };