32 — Retry and deadlines
Effect.retry(schedule) repeats according to an explicit, bounded policy. Effect.timeout(duration) adds a typed TimeoutError and interrupts the underlying fiber when the deadline wins. Use Effect.timeoutOrElse when the domain needs a custom timeout failure.
Retry only transient operations, keep idempotency in view, and put deadlines around the complete operation rather than an arbitrary internal fragment.
The full test suite
The index.test.ts for this lesson, verbatim from steps/32-retry-and-timeout/.
import { describe, expect, it } from "vite-plus/test"import { Effect, Exit, Schedule } from "effect"
describe("retry and timeout", () => { it("keeps retry and deadline policies visible", async () => { const exit = await Effect.runPromiseExit( Effect.fail("unavailable").pipe(Effect.retry(Schedule.recurs(2)), Effect.timeout("50 millis")), ) expect(Exit.isFailure(exit)).toBe(true) })})