warmup.mjs
22 lines 849 B
Raw
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge Human 10 hours ago
1 /**
2 * Scheduled function: pings the gateway Lambda every 5 minutes to prevent cold starts.
3 * Cold-starting the 1.8 MB gateway bundle takes 12+ seconds on Netlify, which exceeds
4 * browser TLS-handshake timeouts and causes ERR_CONNECTION_CLOSED / ERR_TIMED_OUT.
5 * This keeps the Lambda warm so real user requests always hit a hot instance.
6 */
7 export default async () => {
8 const siteUrl = process.env.URL || 'https://knowtation-gateway.netlify.app';
9 try {
10 const res = await fetch(`${siteUrl}/api/v1/auth/providers`, {
11 signal: AbortSignal.timeout(20000),
12 });
13 console.log('[warmup] gateway responded:', res.status);
14 } catch (e) {
15 console.log('[warmup] gateway ping failed (expected on first cold start):', e?.message || String(e));
16 }
17 return new Response('ok');
18 };
19
20 export const config = {
21 schedule: '* * * * *',
22 };
File History 1 commit
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge Human 10 hours ago