mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-10 23:13:44 +00:00
fix(stats): fall back after full sync failure (#41411)
This commit is contained in:
parent
38e10eb140
commit
0bff28de09
2 changed files with 14 additions and 4 deletions
|
|
@ -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<string, string>
|
||||
|
|
|
|||
|
|
@ -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) })}`),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue