All files / src/keep-warm index.ts

0% Statements 0/23
0% Branches 0/1
0% Functions 0/1
0% Lines 0/23

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24                                               
import { app, InvocationContext, Timer } from "@azure/functions";

/**
 * No-op timer that keeps the Consumption-plan worker loaded. Paddle drops a
 * webhook delivery that doesn't respond within 5 seconds, and a cold start
 * here reliably exceeds that (observed 7–12s), so the first delivery attempt
 * of every tier-flip event failed until Paddle retried against a warm
 * instance — pushing upgrades past the ≤1-minute target (SC-004). A 4-minute
 * heartbeat keeps the instance resident (idle unload is ~5–20 min).
 */
export function keepWarmHandler(
  _timer: Timer,
  context: InvocationContext
): Promise<void> {
  context.debug("keep-warm: heartbeat");
  return Promise.resolve();
}

app.timer("keep-warm", {
  schedule: "0 */4 * * * *",
  runOnStartup: false,
  handler: keepWarmHandler,
});