Skip to content

Commit c575723

Browse files
committed
test: pin that maxRetries 0 disables the session-level replay
anomalyco#43596 now also asks for the opposite of what motivated this: turns with side effects need the processor to never replay a failed provider request. Zero already did that, since the policy returns done on attempt 1, but nothing pinned it. Assisted-by: Claude Opus 5.5
1 parent f06e5e6 commit c575723

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎packages/opencode/test/session/retry.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,29 @@ describe("session.retry.delay", () => {
228228
}),
229229
)
230230

231+
it.instance("policy never retries when maxRetries is zero", () =>
232+
Effect.gen(function* () {
233+
const attempts: number[] = []
234+
const error = apiError({ "retry-after-ms": "0" })
235+
const step = yield* Schedule.toStepWithMetadata(
236+
SessionRetry.policy({
237+
provider: "test",
238+
tuning: { maxRetries: 0 },
239+
parse: Schema.decodeUnknownSync(SessionV1.APIError.Schema),
240+
set: (info) =>
241+
Effect.sync(() => {
242+
attempts.push(info.attempt)
243+
}),
244+
}),
245+
)
246+
247+
yield* Effect.forEach(Array.from({ length: 5 }), () => Effect.ignore(step(error)))
248+
249+
// with side effects in play, a failed request must never be replayed
250+
expect(attempts).toStrictEqual([])
251+
}),
252+
)
253+
231254
it.instance("policy keeps retrying when maxRetries is negative", () =>
232255
Effect.gen(function* () {
233256
const attempts: number[] = []

0 commit comments

Comments
 (0)