diff --git a/packages/stats/core/src/athena.ts b/packages/stats/core/src/athena.ts index 96a48d371033..23aba70b3ce6 100644 --- a/packages/stats/core/src/athena.ts +++ b/packages/stats/core/src/athena.ts @@ -9,7 +9,7 @@ import { Effect, Layer } from "effect" import * as Context from "effect/Context" import { Resource } from "sst/resource" -const ATHENA_MAX_POLL_ATTEMPTS = 300 +const ATHENA_MAX_POLL_ATTEMPTS = 900 const ATHENA_PAGE_SIZE = 1000 export type AthenaData = Record diff --git a/packages/stats/server/src/stat-sync.ts b/packages/stats/server/src/stat-sync.ts index dd572d086531..613fbec5b7d4 100644 --- a/packages/stats/server/src/stat-sync.ts +++ b/packages/stats/server/src/stat-sync.ts @@ -19,9 +19,19 @@ const daemon = Effect.gen(function* () { let lastFullDay = "" const pass = Effect.gen(function* () { const today = new Date().toISOString().slice(0, 10) - const full = lastFullDay !== today - yield* syncStats({ full }) - if (full) lastFullDay = today + if (lastFullDay !== today) { + const completed = yield* syncStats({ full: true }).pipe( + Effect.as(true), + Effect.catchCause((cause) => + Effect.logWarning(`full stats sync failed; falling back to incremental sync ${Cause.pretty(cause)}`).pipe( + Effect.as(false), + ), + ), + ) + lastFullDay = today + if (completed) return + } + yield* syncStats({ full: false }) }).pipe( Effect.catchCause((cause) => Effect.logWarning(`stats sync failed ${JSON.stringify({ cause: Cause.pretty(cause) })}`),