Skip to content

Commit f42e7da

Browse files
committed
fix(server): an unparseable usage-limit reset keeps the provider's queue held
1 parent 9370baf commit f42e7da

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎apps/server/src/orchestration-v2/Orchestrator.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,9 @@ function usageLimitHoldsQueue(
898898
if (limited === null) return false;
899899
if (latestExecutedRun(projection.runs)?.id === limited.id) return true;
900900
const resetAt = latestRootProviderFailure(limited, projection.turnItems)?.resetAt;
901-
return resetAt == null || Date.parse(resetAt) > DateTime.toEpochMillis(now);
901+
if (resetAt == null) return true;
902+
const resetMs = Date.parse(resetAt);
903+
return !Number.isFinite(resetMs) || resetMs > DateTime.toEpochMillis(now);
902904
}
903905

904906
function latestStableRun(

‎apps/server/src/orchestration-v2/runtimeLayer.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5954,6 +5954,7 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
59545954
it.effect.each([
59555955
["a known reset", { hours: 1 }, "starting"],
59565956
["an unknown reset", null, "queued"],
5957+
["an unparseable reset", "soon", "queued"],
59575958
] as const)(
59585959
"holds a limited provider's queue through another provider's turn until %s passes",
59595960
([name, resetIn, afterAnHour]) =>
@@ -6030,7 +6031,10 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
60306031
message: "Usage limit reached",
60316032
code: "usage_limit",
60326033
retryable: null,
6033-
resetAt: resetIn === null ? null : DateTime.formatIso(DateTime.add(now, resetIn)),
6034+
resetAt:
6035+
resetIn === null || typeof resetIn === "string"
6036+
? resetIn
6037+
: DateTime.formatIso(DateTime.add(now, resetIn)),
60346038
},
60356039
},
60366040
},

0 commit comments

Comments
 (0)