fluxy-bot 0.5.64 → 0.5.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/supervisor/index.ts +1 -2
- package/supervisor/tunnel.ts +11 -5
package/package.json
CHANGED
package/supervisor/index.ts
CHANGED
|
@@ -866,6 +866,7 @@ export async function startSupervisor() {
|
|
|
866
866
|
const now = Date.now();
|
|
867
867
|
const wakeGap = now - lastTick > 60_000;
|
|
868
868
|
const periodicCheck = ++healthCounter % 10 === 0;
|
|
869
|
+
lastTick = now; // Update immediately so concurrent ticks don't see a stale gap
|
|
869
870
|
|
|
870
871
|
if (wakeGap || periodicCheck) {
|
|
871
872
|
const alive = await isTunnelAlive(tunnelUrl!);
|
|
@@ -917,8 +918,6 @@ export async function startSupervisor() {
|
|
|
917
918
|
}
|
|
918
919
|
}
|
|
919
920
|
}
|
|
920
|
-
|
|
921
|
-
lastTick = now;
|
|
922
921
|
}, 30_000);
|
|
923
922
|
}
|
|
924
923
|
|
package/supervisor/tunnel.ts
CHANGED
|
@@ -117,12 +117,18 @@ export function stopTunnel(): void {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
export async function isTunnelAlive(url: string): Promise<boolean> {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
120
|
+
// Two attempts with a short gap — avoids false positives from transient Cloudflare errors
|
|
121
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
122
|
+
try {
|
|
123
|
+
const res = await fetch(url + `/api/health?_cb=${Date.now()}`, {
|
|
124
|
+
signal: AbortSignal.timeout(8000),
|
|
125
|
+
headers: { 'Cache-Control': 'no-cache, no-store' },
|
|
126
|
+
});
|
|
127
|
+
if (res.status !== 502 && res.status !== 503) return true;
|
|
128
|
+
} catch {}
|
|
129
|
+
if (attempt === 0) await new Promise(r => setTimeout(r, 3000));
|
|
125
130
|
}
|
|
131
|
+
return false;
|
|
126
132
|
}
|
|
127
133
|
|
|
128
134
|
export async function restartTunnel(port: number): Promise<string> {
|