Skip to content

Commit 0bff28d

Browse files
fix(stats): fall back after full sync failure (#41411)
1 parent 38e10eb commit 0bff28d

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

‎packages/stats/core/src/athena.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Effect, Layer } from "effect"
99
import * as Context from "effect/Context"
1010
import { Resource } from "sst/resource"
1111

12-
const ATHENA_MAX_POLL_ATTEMPTS = 300
12+
const ATHENA_MAX_POLL_ATTEMPTS = 900
1313
const ATHENA_PAGE_SIZE = 1000
1414

1515
export type AthenaData = Record<string, string>

‎packages/stats/server/src/stat-sync.ts‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,19 @@ const daemon = Effect.gen(function* () {
1919
let lastFullDay = ""
2020
const pass = Effect.gen(function* () {
2121
const today = new Date().toISOString().slice(0, 10)
22-
const full = lastFullDay !== today
23-
yield* syncStats({ full })
24-
if (full) lastFullDay = today
22+
if (lastFullDay !== today) {
23+
const completed = yield* syncStats({ full: true }).pipe(
24+
Effect.as(true),
25+
Effect.catchCause((cause) =>
26+
Effect.logWarning(`full stats sync failed; falling back to incremental sync ${Cause.pretty(cause)}`).pipe(
27+
Effect.as(false),
28+
),
29+
),
30+
)
31+
lastFullDay = today
32+
if (completed) return
33+
}
34+
yield* syncStats({ full: false })
2535
}).pipe(
2636
Effect.catchCause((cause) =>
2737
Effect.logWarning(`stats sync failed ${JSON.stringify({ cause: Cause.pretty(cause) })}`),

0 commit comments

Comments
 (0)