warmup.mjs
22 lines 849 B
Raw
sha256:baa800aedf841dbf32081aa7b2befa288ac33dfc7175ac55014c55c4d8c742f9 docs: move durable-auth freeze/evidence to local developmen… Human 11 days 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:baa800aedf841dbf32081aa7b2befa288ac33dfc7175ac55014c55c4d8c742f9 docs: move durable-auth freeze/evidence to local developmen… Human 11 days ago