aboutsummaryrefslogtreecommitdiffstats
path: root/lib/health.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-24 13:18:42 -0800
committerAdam Soltys <[email protected]>2026-02-24 13:18:42 -0800
commitad7b09b43323d0ffc0a8ddabb43e4838a184c697 (patch)
treefbf2a59f81771b2938f474c8e7b35a497d2960e4 /lib/health.ts
parent9e97e040617bfa0b40150c0eba298bf186bbeeaf (diff)
downloadcoinos-server-ad7b09b43323d0ffc0a8ddabb43e4838a184c697.tar.gz
coinos-server-ad7b09b43323d0ffc0a8ddabb43e4838a184c697.zip
formatting
Diffstat (limited to 'lib/health.ts')
-rw-r--r--lib/health.ts29
1 files changed, 12 insertions, 17 deletions
diff --git a/lib/health.ts b/lib/health.ts
index c2e268c6..fbefa8fa 100644
--- a/lib/health.ts
+++ b/lib/health.ts
@@ -22,13 +22,16 @@ export function getHealthStatus() {
function withTimeout<T>(promise: Promise<T>, ms: number, label: string): Promise<T> {
return new Promise((resolve, reject) => {
- const timer = setTimeout(
- () => reject(new Error(`${label} timed out after ${ms}ms`)),
- ms,
- );
+ const timer = setTimeout(() => reject(new Error(`${label} timed out after ${ms}ms`)), ms);
promise.then(
- (v) => { clearTimeout(timer); resolve(v); },
- (e) => { clearTimeout(timer); reject(e); },
+ (v) => {
+ clearTimeout(timer);
+ resolve(v);
+ },
+ (e) => {
+ clearTimeout(timer);
+ reject(e);
+ },
);
});
}
@@ -79,11 +82,7 @@ async function checkLightningHealth(): Promise<boolean> {
const errorCode = e?.code ?? e?.errno ?? "unknown";
const errorMsg = e?.message ?? String(e);
- err(
- `health check: FAILED after ${duration}ms`,
- `code=${errorCode}`,
- `error=${errorMsg}`,
- );
+ err(`health check: FAILED after ${duration}ms`, `code=${errorCode}`, `error=${errorMsg}`);
if (e instanceof LightningUnavailableError) {
err("health check: lightning RPC socket unavailable");
@@ -102,18 +101,14 @@ export async function runHealthCheck() {
if (healthy) {
if (consecutiveFailures > 0) {
- l(
- `health check: recovered after ${consecutiveFailures} consecutive failures`,
- );
+ l(`health check: recovered after ${consecutiveFailures} consecutive failures`);
}
consecutiveFailures = 0;
lastSuccessTime = Date.now();
lastFailureReason = "";
} else {
consecutiveFailures++;
- warn(
- `health check: failure ${consecutiveFailures}/${MAX_CONSECUTIVE_FAILURES}`,
- );
+ warn(`health check: failure ${consecutiveFailures}/${MAX_CONSECUTIVE_FAILURES}`);
if (consecutiveFailures >= MAX_CONSECUTIVE_FAILURES) {
err(