mirror of
https://github.com/vercel/workflow.git
synced 2026-09-14 19:59:43 +08:00
fe12b84729
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).
18 lines
414 B
TypeScript
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;
|
|
}
|