Skip to content

Feature: Expose isLastAttempt/maxAttempts in step metadata #4979

Open

Description

@pensono

I would like to write a step like this, which will handle an error differently on the last attempt. Is there anything in the step metadata which would allow me to detect if this run of the step is the last one?

export async function myStep<T>() {
  "use step";
  try {
    return await execute();
  } catch (error) {
    if (!FatalError.is(error) && getStepMetadata().attempt < getStepMetadata().maxAttempts) {
      throw error;
    }
    console.error(error);
    return undefined;
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions