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:
- Be automatically wrapped in a
TerminalError by the SDK (since all inner errors are TerminalErrors), or
- 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).