vercel / vercel/workflow

Workflow graph analyzer stack overflow on recursive workflow calls

Open
#851 0 comments 0 reactions 1 assignee View on GitHub

@karthikscale3 is already working on this.

Since Jan 27, 2026.

Dominant language
TypeScript
Stars
2.4k
Forks
365
Avg merge
2d 11h
Merged PRs (30d)
169

Description

Description

The workflow graph analyzer throws a RangeError: Maximum call stack size exceeded when analyzing workflows that contain recursive calls to themselves.

Error Message

Failed to extract workflow graphs from bundle: RangeError: Maximum call stack size exceeded

Steps to Reproduce

  1. Create a workflow that calls itself recursively under certain conditions:
export async function myWorkflow(params: MyParams): Promise<MyResult> {
  "use workflow";
  
  // ... do some work ...
  
  const result = await someStep();
  
  // Recursive call under certain conditions
  if (result.score < threshold && params.canRetry) {
    return myWorkflow({
      ...params,
      canRetry: false,  // Prevent infinite recursion at runtime
    });
  }
  
  return result;
}
  1. Run npm run dev or trigger the workflow graph extraction

  2. The graph analyzer enters infinite recursion trying to trace the workflow

Expected Behavior

The graph analyzer should detect recursive workflow calls and handle them gracefully, either by:

  • Detecting the cycle and stopping traversal
  • Emitting a warning about recursive workflows
  • Documenting that recursive workflows are not supported

Actual Behavior

Stack overflow crash during graph analysis, blocking the dev server from starting properly.

Workaround

Replace recursive workflow calls with an internal loop structure that achieves the same logic without self-reference.

Environment

  • workflow: 4.0.1-beta.50
  • next: 16.1.3
  • Node.js: v22.x

Additional Context

The recursive pattern is useful for "quality guarantee" features where a workflow retries with different parameters (e.g., escalating to a premium tier) if initial results don't meet a threshold. While the workaround works, native support for recursive workflows or clear documentation about this limitation would be helpful.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.