Skip to content

Commit

Permalink
Heartbeat: implement in both live-reload servers
Browse files Browse the repository at this point in the history
  • Loading branch information
developit authored Jul 21, 2023
1 parent 3ecd4d5 commit 69d09ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/remix-dev/devServer/liveReload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@ export async function liveReload(config: RemixConfig) {
}
);

let heartbeat = setInterval(broadcast, 60000, { type: "PING" });

exitHook(() => clean(config));
return async () => {
wss.close();
clearInterval(heartbeat);
await dispose();
};
}
9 changes: 8 additions & 1 deletion packages/remix-dev/devServer_unstable/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
};

0 comments on commit 69d09ef

Please sign in to comment.