Skip to content

workflow: retry a step at the time it asks for - #302

Open
fantix wants to merge 1 commit into
mainfrom
fantix/retryable-error
Open

workflow: retry a step at the time it asks for#302
fantix wants to merge 1 commit into
mainfrom
fantix/retryable-error

Conversation

@fantix

@fantix fantix commented Aug 15, 2026

Copy link
Copy Markdown
Member

This PR adds a new public API - a new error type vercel.workflow.RetryableError.

from vercel.workflow import FatalError, RetryableError


@app.step(max_retries=5)
async def charge_customer(customer_id: str) -> None:
    if not customer_id:
        # Retrying cannot help, so fail the step on this attempt.
        raise FatalError("no customer")
    response = await http.post(...)
    if response.status_code == 429:
        # Retry, but not before the API says we may.
        raise RetryableError("rate limited", retry_after="10s")

RetryableError("rate limited", retry_after="10s") sets how long to wait before a step's next attempt, mirroring RetryableError in TS @workflow/errors. retry_after accepts what sleep() accepts and defaults to one second. It changes when the next attempt runs, not how many attempts there are.

The deadline is recorded twice in _execute_step() in runtime.py. The QueueContinuation.delay_seconds delays this delivery; the StepRetryingEventData.retryAfter persisted on the step is used by the world (like workflow server) to prevent staring the step too early (returning TooEarlyError if so).

fantix added a commit that referenced this pull request Aug 15, 2026
Integration-branch only. #300 gave `World.events_create` its `resume`
parameter and updated every test double in the tree; #302's double was
written against `main`, where neither the parameter nor `HookResume` exists
yet. Stacking the two is what makes them disagree, so the fix belongs here
rather than in either PR, and it disappears once both land.
@fantix
fantix marked this pull request as draft August 15, 2026 17:47
@fantix
fantix force-pushed the fantix/retryable-error branch from c109a24 to a1e6d9a Compare August 20, 2026 03:17
@fantix
fantix marked this pull request as ready for review August 20, 2026 03:34
@fantix
fantix requested a review from a team August 20, 2026 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant