Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cloudflare-gastown/src/dos/town/reconciler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const CIRCUIT_BREAKER_WINDOW_MINUTES = 30;
* beads that eventually succeeded (status = 'closed').
*/
function checkDispatchCircuitBreaker(sql: SqlStorage): Action[] {
const cutoff = new Date(Date.now() - CIRCUIT_BREAKER_WINDOW_MINUTES * 60_000).toISOString();
const rows = z
.object({ failure_count: z.number() })
.array()
Expand All @@ -61,11 +62,11 @@ function checkDispatchCircuitBreaker(sql: SqlStorage): Action[] {
/* sql */ `
SELECT count(*) as failure_count
FROM ${beads}
WHERE ${beads.last_dispatch_attempt_at} > strftime('%Y-%m-%dT%H:%M:%fZ', 'now', '-${CIRCUIT_BREAKER_WINDOW_MINUTES} minutes')
WHERE ${beads.last_dispatch_attempt_at} > ?
AND ${beads.dispatch_attempts} > 0
AND ${beads.status} != 'closed'
`,
[]
[cutoff]
),
]);

Expand Down