fluxy-bot 0.5.21 → 0.5.23
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 +18 -5
- package/worker/index.ts +9 -0
package/package.json
CHANGED
package/supervisor/index.ts
CHANGED
|
@@ -715,14 +715,27 @@ export async function startSupervisor() {
|
|
|
715
715
|
}
|
|
716
716
|
}
|
|
717
717
|
|
|
718
|
-
// Poll until the full chain is actually working
|
|
718
|
+
// Poll until the full relay→tunnel→server chain is actually working.
|
|
719
|
+
// A 502/503 means the relay can't reach the tunnel yet; anything else
|
|
720
|
+
// (200, 401, 403, etc.) means the chain is live.
|
|
719
721
|
const probeUrl = config.relay?.url || tunnelUrl;
|
|
720
722
|
let ready = false;
|
|
721
|
-
|
|
723
|
+
log.info(`Readiness probe: polling ${probeUrl}`);
|
|
724
|
+
for (let i = 0; i < 30; i++) {
|
|
722
725
|
try {
|
|
723
|
-
const res = await fetch(probeUrl +
|
|
724
|
-
|
|
725
|
-
|
|
726
|
+
const res = await fetch(probeUrl + `/api/health?_cb=${Date.now()}`, {
|
|
727
|
+
signal: AbortSignal.timeout(3000),
|
|
728
|
+
headers: { 'Cache-Control': 'no-cache, no-store' },
|
|
729
|
+
});
|
|
730
|
+
log.info(`Readiness probe #${i + 1}: ${res.status}`);
|
|
731
|
+
// Any non-502/503 means the relay is reaching the tunnel
|
|
732
|
+
if (res.status !== 502 && res.status !== 503) {
|
|
733
|
+
ready = true;
|
|
734
|
+
break;
|
|
735
|
+
}
|
|
736
|
+
} catch (err) {
|
|
737
|
+
log.info(`Readiness probe #${i + 1}: ${err instanceof Error ? err.message : 'error'}`);
|
|
738
|
+
}
|
|
726
739
|
await new Promise(r => setTimeout(r, 1000));
|
|
727
740
|
}
|
|
728
741
|
if (!ready) {
|
package/worker/index.ts
CHANGED
|
@@ -63,6 +63,15 @@ initWebPush();
|
|
|
63
63
|
const app = express();
|
|
64
64
|
app.use(express.json({ limit: '10mb' }));
|
|
65
65
|
|
|
66
|
+
// Prevent browsers/CDN/relay from caching API responses (avoids stale 502s)
|
|
67
|
+
app.use('/api', (_, res, next) => {
|
|
68
|
+
res.set('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate');
|
|
69
|
+
res.set('Pragma', 'no-cache');
|
|
70
|
+
res.set('Expires', '0');
|
|
71
|
+
res.set('Surrogate-Control', 'no-store');
|
|
72
|
+
next();
|
|
73
|
+
});
|
|
74
|
+
|
|
66
75
|
app.get('/api/health', (_, res) => res.json({ status: 'ok' }));
|
|
67
76
|
app.get('/api/conversations', (_, res) => res.json(listConversations()));
|
|
68
77
|
app.get('/api/conversations/:id', (req, res) => {
|