Skip to content
Source
Sign inSign up
pingdotgg/t3code

Back off checkpoint capture after repeated failures #4517

Closedyashranaway(GitHub profile, opens in a new tab)wants to merge 5 commits intomain fromrefs/pull/4517/headopened View on GitHub

Showing 4 changed files with 191 additions and 0 deletions (loading 3).

x
0 of 4 viewed, 4 left
191 additions and 0 deletionsapps/server/src/checkpointing/CaptureBackoff.test.tsAdded
View file
@@ -0,0 +1,191 @@
+import { describe, expect, it } from "vite-plus/test";
+​
+import { cooldownForFailureCount, makeCaptureBackoff } from "./CaptureBackoff.ts";
+​
+const MINUTE = 60_000;
+const CWD = "/repo/workspace";
+​
+describe("cooldownForFailureCount", () => {
+ it("tolerates transient failures before opening a cooldown", () => {
+ expect(cooldownForFailureCount(1)).toBe(0);
+ expect(cooldownForFailureCount(2)).toBe(0);
+ });
+​
+ it("backs off further the longer capture keeps failing", () => {
+ expect(cooldownForFailureCount(3)).toBe(5 * MINUTE);
+ expect(cooldownForFailureCount(4)).toBe(10 * MINUTE);
+ expect(cooldownForFailureCount(5)).toBe(20 * MINUTE);
+ });
+​
+ it("caps the cooldown so a workspace is retried eventually", () => {
+ expect(cooldownForFailureCount(20)).toBe(60 * MINUTE);
+ expect(cooldownForFailureCount(500)).toBe(60 * MINUTE);
+ });
+});
+​
+describe("makeCaptureBackoff", () => {
+ it("does not skip before the failure threshold is reached", () => {
+ const backoff = makeCaptureBackoff<string>();
+​
+ backoff.recordFailure(CWD, 0, "timeout");