Skip to content

Expose attempt count in status() query for better observability #15

@mmikita95

Description

@mmikita95

Problem

Currently, the status() query only returns whether a run is inProgress or completed, but doesn't expose how many retry attempts have been made. This makes it difficult to provide users with transparency about background operations (i.e. show retry progress in UI, "Attempt 3 of 5"), or to complement the retry logic based on attempt count.

Current Behavior

const status = await retrier.status(ctx, runId);
// returns: 
{ type: "inProgress" } 
// or: 
{ type: "completed", result: RunResult }

No visibility into how many retries have occurred or how many remain.

Proposed Solution

Expose numFailures and optionally maxFailures in the status response:

const status = await retrier.status(ctx, runId);
// returns:
{ type: "inProgress", numFailures: 3, maxFailures: 5 }
// or
{ type: "completed", result: RunResult, numFailures: 3 }

Implementation

The data already exists in the runs table:

  • run.numFailures - current attempt count
  • run.options.maxFailures - max attempts configured

As it appears to me, this would be a low-impact change to public.ts:status() to include these fields in the return value.

Use Case

We're using action-retrier for infrastructure provisioning operations that can take several minutes and occasionally hit transient API errors. Being able to show users "Provisioning... (Attempt 2 of 5)" provides much better UX than just "Provisioning..." and helps distinguish between "still working" vs "stuck in retry loop" scenarios.

Alternative Considered

We considered tracking this in our own table, but that would duplicate data that action-retrier already maintains internally. Since the retry logic and attempt counting are tightly coupled, it seemed better to request this feature rather than maintain parallel state that could drift out of sync.


Thank you for your attention! Happy to contribute a PR if that would be helpful. Would love to hear back from you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions