ThrottleError
Thrown when a request is rate-limited by the workflow backend.
ThrottleError is thrown when a request to the workflow backend is rate-limited. It corresponds to HTTP 429 Too Many Requests semantics.
The retryAfter property contains the number of seconds to wait before retrying.
The Workflow runtime handles this error automatically by backing off and retrying. You will only encounter it when interacting with world storage APIs directly.
import { ThrottleError } from "workflow/errors"
declare const world: { events: { create(...args: any[]): Promise<any> } }; // @setup
declare const runId: string; // @setup
declare const event: any; // @setup
try {
await world.events.create(runId, event);
} catch (error) {
if (ThrottleError.is(error)) {
console.log(`Rate limited. Retry after ${error.retryAfter} seconds`);
}
}API Signature
Properties
| Name | Type | Description |
|---|---|---|
retryAfter | number | The number of seconds to wait before retrying. Present when the server sends a Retry-After header. |
message | string | The error message. |
Static Methods
ThrottleError.is(value)
Type-safe check for ThrottleError instances. Preferred over instanceof because it works across module boundaries and VM contexts.
import { ThrottleError } from "workflow/errors"
declare const error: unknown; // @setup
if (ThrottleError.is(error)) {
// error is typed as ThrottleError
}