Summary
Workflow steps are correctly discovered in manifest.json under steps, but the generated workflow graph is empty (start -> end) even when the workflow clearly awaits step functions.
This appears to be caused by the graph extractor in @workflow/builders being too strict when parsing transformed step declarations.
Expected behavior
Given a workflow that:
- declares
"use workflow"
- awaits multiple imported step functions in sequence
The generated workflow graph should include nodes for each awaited step.
Actual behavior
manifest.json correctly lists all steps under steps
- but the workflow graph only contains:
No intermediate step nodes are included.
Reproduction (minimal example)
- Create a workflow file:
export async function testWorkflow(input) {
'use workflow';
const a = await stepOne(input);
const b = await stepTwo(a);
const c = await stepThree(b);
return c;
}
- Define each step in separate files, each starting with:
- Run the build and inspect the generated manifest.
Evidence
steps in the manifest includes all expected step entries
- but
workflows.<workflow>.graph.nodes only includes start and end
Likely cause
In the transformed bundle, step declarations look like:
var stepOne = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("...");
However, the extractor in @workflow/builders/dist/workflows-extractor.js appears to rely on a regex similar to:
/var (\w+) = globalThis\[Symbol\.for\("WORKFLOW_USE_STEP"\)\]\("([^"]+)"\)/
This does not match when the bundler injects /* @__PURE__ */ inside the computed property access.
As a result:
- step registration succeeds
- graph extraction fails
Proposed solution
Update the extractor regex to tolerate optional annotations inside the computed access.
For example:
/var (\w+) = globalThis\[(?:\/\*\s*@__PURE__\s*\*\/\s*)?Symbol\.for\("WORKFLOW_USE_STEP"\)\]\("([^"]+)"\)/
This allows the extractor to correctly match both annotated and non-annotated builds.
Environment
- Workflow SDK: @latest
- Next.js: 16.16.2.3 (Turbopack)
- Turbopack (dev)
Summary
Workflow steps are correctly discovered in
manifest.jsonundersteps, but the generated workflow graph is empty (start -> end) even when the workflow clearly awaits step functions.This appears to be caused by the graph extractor in
@workflow/buildersbeing too strict when parsing transformed step declarations.Expected behavior
Given a workflow that:
"use workflow"The generated workflow graph should include nodes for each awaited step.
Actual behavior
manifest.jsoncorrectly lists all steps understepsStartReturnNo intermediate step nodes are included.
Reproduction (minimal example)
Evidence
stepsin the manifest includes all expected step entriesworkflows.<workflow>.graph.nodesonly includesstartandendLikely cause
In the transformed bundle, step declarations look like:
However, the extractor in
@workflow/builders/dist/workflows-extractor.jsappears to rely on a regex similar to:/var (\w+) = globalThis\[Symbol\.for\("WORKFLOW_USE_STEP"\)\]\("([^"]+)"\)/This does not match when the bundler injects
/* @__PURE__ */inside the computed property access.As a result:
Proposed solution
Update the extractor regex to tolerate optional annotations inside the computed access.
For example:
/var (\w+) = globalThis\[(?:\/\*\s*@__PURE__\s*\*\/\s*)?Symbol\.for\("WORKFLOW_USE_STEP"\)\]\("([^"]+)"\)/This allows the extractor to correctly match both annotated and non-annotated builds.
Environment