Files
vercel__workflow/packages/world-testing/workflows/event-limit.ts
Shalabh Chaturvedi fe12b84729 Implement max_events per run limit (#2986)
Enforces the published per-run events limit, which was previously not enforced. The server supplies the limit on the run_started response (separate change); once a run's event log reaches it, the runtime throws MaxEventsExceededError at the top of the replay loop, and the existing terminal-error path records it as run_failed with a new MAX_EVENTS_EXCEEDED code — instead of letting a runaway workflow (e.g. an unbounded step loop) grow the event log without bound.

Adds a new client side WORKFLOW_MAX_EVENTS_OVERRIDE env var which can override the server side provided value (lower only).
2026-07-21 17:21:26 -07:00

18 lines
414 B
TypeScript

async function tick(i: number): Promise<number> {
'use step';
return i;
}
/**
* Runaway workflow: creates far more events than a low `WORKFLOW_MAX_EVENTS`
* ceiling, so the event-limit guard fails it before the loop finishes.
*/
export async function runawayWorkflow(): Promise<number> {
'use workflow';
let total = 0;
for (let i = 0; i < 15; i++) {
total += await tick(i);
}
return total;
}