Skip to content

Commit

Permalink
Handle temporary disconnections in the runtimeRestarter (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzadp authored Jun 18, 2024
1 parent f17618f commit 5f7adf5
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/runtimeRestarter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,21 @@ export function runtimeRestarter(opts: {
}
};

const tryRunChecks = async () => {
try {
await runChecks();
} catch (e) {
if (e instanceof Error && e.message.includes("WebSocket is not connected")) {
log?.("Failed to check for metadata/runtime changes due to disconnected websocket. Will continue trying.");
return;
}
throw e;
}
};

const checkIntervalSeconds = opts.checkIntervalSeconds ?? 600;
const interval = setInterval(() => {
void runChecks();
void tryRunChecks();
}, checkIntervalSeconds * 1000);

return () => clearInterval(interval);
Expand Down

0 comments on commit 5f7adf5

Please sign in to comment.