Skip to content

RestatePromise.any with all-rejected promises throws AggregateError instead of TerminalError #672

@slinkydeveloper

Description

@slinkydeveloper

Problem

When all promises passed to RestatePromise.any() are rejected (e.g. via RestatePromise.reject()), the resulting AggregateError thrown by Promise.any() is not a TerminalError. This causes Restate to retry the invocation indefinitely instead of failing terminally.

Expected behavior

The AggregateError should either:

  1. Be automatically wrapped in a TerminalError by the SDK (since all inner errors are TerminalErrors), or
  2. Be documented as a known behavior with guidance on how to handle it

Reproduction

const promises = ["err1", "err2"].map((m) =>
  RestatePromise.reject<string>(new restate.TerminalError(m))
);
// This throws AggregateError (not TerminalError), causing infinite retries
return RestatePromise.any(promises);

Context

Found while adding e2e tests for RestatePromise.resolve/RestatePromise.reject (PR #611).

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