Skip to content

Normalize anonymous default export workflow IDs to "default" - #484

Merged
TooTallNate merged 3 commits into
mainfrom
12-02-normalize_anonymous_default_export_workflow_ids_to_default_
Dec 2, 2025
Merged

Normalize anonymous default export workflow IDs to "default"#484
TooTallNate merged 3 commits into
mainfrom
12-02-normalize_anonymous_default_export_workflow_ids_to_default_

Conversation

@TooTallNate

@TooTallNateTooTallNate commented Dec 2, 2025

Copy link
Copy Markdown
Member

So that we show "default" as the workflow name in o11y UI instead of "__default"

@changeset-bot

changeset-botBot commented Dec 2, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0346122

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
NameType
@workflow/swc-pluginPatch
@workflow/astroPatch
@workflow/buildersPatch
@workflow/cliPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
workflowPatch
@workflow/world-testingPatch
@workflow/nuxtPatch
@workflow/aiPatch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercelBot commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

@github-actions

github-actionsBot commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

📈 Comparing against baseline from main branch. Green 🟢 = faster, Red 🔺 = slower.

workflow with no steps

WorldFrameworkWorkflow TimeWall TimeOverheadvs Fastest
💻 Local🥇 Next.js (Turbopack)0.042s (+11.3% 🔺)1.018s (~)0.976s1.00x
💻 LocalNitro0.043s (-0.9%)1.007s (~)0.963s1.02x
💻 LocalExpress0.043s (-2.2%)1.007s (~)0.963s1.03x
🐘 PostgresExpress0.230s (-3.4%)1.021s (+0.7%)0.791s5.43x
🐘 PostgresNitro0.348s (+50.9% 🔺)1.011s (-1.2%)0.664s8.22x
🐘 PostgresNext.js (Turbopack)0.411s (+2.6%)1.025s (~)0.614s9.72x
▲ VercelNext.js (Turbopack)0.479s (-1.2%)1.531s (+2.1%)1.052s11.32x
▲ VercelNitro0.496s (-9.3% 🟢)1.356s (-3.9%)0.860s11.72x
▲ VercelExpress0.527s (-26.0% 🟢)1.525s (+1.3%)0.997s12.47x

workflow with 1 step

WorldFrameworkWorkflow TimeWall TimeOverheadvs Fastest
💻 Local🥇 Next.js (Turbopack)0.095s (+19.4% 🔺)1.011s (~)0.916s1.00x
💻 LocalNitro0.111s (~)1.005s (~)0.894s1.17x
💻 LocalExpress0.114s (~)1.006s (~)0.892s1.20x
🐘 PostgresNext.js (Turbopack)0.712s (-20.7% 🟢)1.015s (-16.5% 🟢)0.303s7.51x
🐘 PostgresExpress0.949s (-14.1% 🟢)1.114s (-44.6% 🟢)0.165s10.01x
🐘 PostgresNitro1.237s (+6.6% 🔺)2.010s (~)0.773s13.05x
▲ VercelNext.js (Turbopack)1.512s (-26.4% 🟢)2.528s (-7.0% 🟢)1.016s15.95x
▲ VercelNitro1.515s (-8.3% 🟢)2.410s (-2.7%)0.895s15.98x
▲ VercelExpress1.604s (~)2.671s (+6.6% 🔺)1.066s16.92x

workflow with 10 sequential steps

WorldFrameworkWorkflow TimeWall TimeOverheadvs Fastest
💻 Local🥇 Next.js (Turbopack)0.647s (+27.4% 🔺)1.010s (~)0.363s1.00x
💻 LocalExpress0.775s (~)1.005s (~)0.230s1.20x
💻 LocalNitro0.781s (-0.8%)1.006s (~)0.225s1.21x
🐘 PostgresNext.js (Turbopack)5.196s (~)6.022s (~)0.827s8.03x
🐘 PostgresExpress5.335s (-49.2% 🟢)6.019s (-45.4% 🟢)0.684s8.24x
🐘 PostgresNitro10.138s (+96.3% 🔺)11.018s (+89.5% 🔺)0.879s15.66x
▲ VercelNext.js (Turbopack)10.539s (-4.5%)11.092s (-4.8%)0.553s16.28x
▲ VercelNitro10.659s (-2.4%)11.347s (-2.3%)0.688s16.46x
▲ VercelExpress11.015s (+0.8%)11.881s (~)0.866s17.01x

workflow with 10 parallel steps

WorldFrameworkWorkflow TimeWall TimeOverheadvs Fastest
💻 Local🥇 Next.js (Turbopack)0.392s (-3.7%)1.011s (~)0.618s1.00x
💻 LocalExpress0.399s (~)1.005s (~)0.606s1.02x
💻 LocalNitro0.404s (+0.7%)1.006s (~)0.602s1.03x
🐘 PostgresExpress0.821s (-48.4% 🟢)1.218s (-39.5% 🟢)0.397s2.09x
🐘 PostgresNext.js (Turbopack)1.157s (+43.9% 🔺)1.457s (+43.5% 🔺)0.299s2.95x
🐘 PostgresNitro1.356s (+22.9% 🔺)2.012s (+24.3% 🔺)0.656s3.46x
▲ VercelExpress2.761s (-14.1% 🟢)3.838s (-1.3%)1.077s7.04x
▲ VercelNitro2.913s (-2.5%)3.684s (~)0.772s7.43x
▲ VercelNext.js (Turbopack)3.060s (+13.5% 🔺)4.026s (+14.7% 🔺)0.966s7.80x

Stream Benchmarks

Stream benchmarks include Time to First Byte (TTFB) metrics.

workflow with stream

WorldFrameworkWorkflow TimeTTFBWall TimeOverheadvs Fastest
💻 Local🥇 Next.js (Turbopack)0.145s (+27.3% 🔺)1.003s (~)1.015s (~)0.869s1.00x
💻 LocalExpress0.175s (-4.5%)0.992s (~)1.009s (~)0.834s1.20x
💻 LocalNitro0.180s (~)0.992s (~)1.008s (~)0.828s1.24x
🐘 PostgresExpress0.846s (-62.2% 🟢)1.226s (-56.3% 🟢)1.312s (-56.5% 🟢)0.466s5.82x
🐘 PostgresNext.js (Turbopack)1.122s (-21.4% 🟢)1.922s (+18.8% 🔺)2.020s (~)0.898s7.72x
🐘 PostgresNitro1.454s (+91.5% 🔺)1.587s (+86.6% 🔺)2.010s (+99.2% 🔺)0.556s10.00x
▲ VercelNitro2.423s (~)3.076s (+12.2% 🔺)3.491s (+13.4% 🔺)1.068s16.66x
▲ VercelExpress2.531s (+5.2% 🔺)3.125s (+13.9% 🔺)3.579s (+15.2% 🔺)1.048s17.41x
▲ VercelNext.js (Turbopack)2.600s (-13.8% 🟢)3.085s (-8.0% 🟢)3.504s (-6.1% 🟢)0.904s17.88x

Summary: Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNext.js (Turbopack)5/5
🐘 PostgresExpress3/5
▲ VercelNext.js (Turbopack)3/5

Summary: Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express💻 Local5/5
Next.js (Turbopack)💻 Local5/5
Nitro💻 Local5/5
Column Definitions
  • Workflow Time: Runtime reported by workflow (completedAt - createdAt) - primary metric
  • TTFB: Time to First Byte - time from workflow start until first stream byte received (stream benchmarks only)
  • Wall Time: Total testbench time (trigger workflow + poll for result)
  • Overhead: Testbench overhead (Wall Time - Workflow Time)
  • vs Fastest: How much slower compared to the fastest configuration for this benchmark

Worlds:

  • 💻 Local: In-memory filesystem world
  • 🐘 Postgres: PostgreSQL database world
  • ▲ Vercel: Vercel production world

@TooTallNateGraphite App

TooTallNate commented Dec 2, 2025

Copy link
Copy Markdown
MemberAuthor

This stack of pull requests is managed by Graphite. Learn more about stacking.

.into_iter()
.map(|fn_name| {
// Check if this export name has a different const name (e.g., "default" -> "__default")
// Use the export name for the workflow ID (e.g., "default" not "__default")

@vercelvercelBotDec 2, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The metadata comment generation was simplified to always use "default" as the workflow ID for default exports, but this creates an inconsistency for named default exports where the actual function property gets a different workflow ID.

View Details
📝 Patch Details
diff --git a/packages/swc-plugin-workflow/transform/src/lib.rs b/packages/swc-plugin-workflow/transform/src/lib.rs
index 35a7d1d..a89f7fb 100644
--- a/packages/swc-plugin-workflow/transform/src/lib.rs+++ b/packages/swc-plugin-workflow/transform/src/lib.rs@@ -2684,13 +2684,34 @@ impl StepTransform {
let workflow_entries: Vec<String> = sorted_workflow_names
.into_iter()
.map(|fn_name| {
- // Use the export name for the workflow ID (e.g., "default" not "__default")
let fn_name_str: &str = fn_name;
- let workflow_id = self.create_id(Some(fn_name_str), DUMMY_SP, true);- format!("\"{}\":{{\"workflowId\":\"{}\"}}", fn_name_str, workflow_id)++ // For default exports, determine the actual function name+ // Apply the same normalization logic as create_workflow_id_assignment+ let actual_fn_name = if fn_name_str == "default" {+ // Look up the actual const name for this default export+ if let Some(const_name) = self.workflow_export_to_const_name.get("default") {+ // Check if this is an auto-generated __default variant+ if (const_name == "__default" || const_name.starts_with("__default$")) {+ // Auto-generated: use "default" as the key+ "default"+ } else {+ // Named: use the actual function name+ const_name.as_str()+ }+ } else {+ // Fallback to "default" if mapping not found+ "default"+ }+ } else {+ fn_name_str+ };++ let workflow_id = self.create_id(Some(actual_fn_name), DUMMY_SP, true);+ format!("\"{}\":{{\"workflowId\":\"{}\"}}", actual_fn_name, workflow_id)+
})
.collect();
-
metadata.insert("workflows", format!("{{{}}}", workflow_entries.join(",")));
}
diff --git a/packages/swc-plugin-workflow/transform/tests/fixture/workflow-client-property/output-client.js b/packages/swc-plugin-workflow/transform/tests/fixture/workflow-client-property/output-client.js
index 55698e3..32024d9 100644
--- a/packages/swc-plugin-workflow/transform/tests/fixture/workflow-client-property/output-client.js+++ b/packages/swc-plugin-workflow/transform/tests/fixture/workflow-client-property/output-client.js@@ -1,5 +1,5 @@
// Test workflow functions in client mode
-/**__internal_workflows{"workflows":{"input.js":{"arrowWorkflow":{"workflowId":"workflow//input.js//arrowWorkflow"},"default":{"workflowId":"workflow//input.js//default"},"internalWorkflow":{"workflowId":"workflow//input.js//internalWorkflow"},"myWorkflow":{"workflowId":"workflow//input.js//myWorkflow"}}}}*/;+/**__internal_workflows{"workflows":{"input.js":{"arrowWorkflow":{"workflowId":"workflow//input.js//arrowWorkflow"},"defaultWorkflow":{"workflowId":"workflow//input.js//defaultWorkflow"},"internalWorkflow":{"workflowId":"workflow//input.js//internalWorkflow"},"myWorkflow":{"workflowId":"workflow//input.js//myWorkflow"}}}}*/;
export async function myWorkflow() {
throw new Error("You attempted to execute workflow myWorkflow function directly. To start a workflow, use start(myWorkflow) from workflow/api");
}
diff --git a/packages/swc-plugin-workflow/transform/tests/fixture/workflow-client-property/output-step.js b/packages/swc-plugin-workflow/transform/tests/fixture/workflow-client-property/output-step.js
index 55698e3..32024d9 100644
--- a/packages/swc-plugin-workflow/transform/tests/fixture/workflow-client-property/output-step.js+++ b/packages/swc-plugin-workflow/transform/tests/fixture/workflow-client-property/output-step.js@@ -1,5 +1,5 @@
// Test workflow functions in client mode
-/**__internal_workflows{"workflows":{"input.js":{"arrowWorkflow":{"workflowId":"workflow//input.js//arrowWorkflow"},"default":{"workflowId":"workflow//input.js//default"},"internalWorkflow":{"workflowId":"workflow//input.js//internalWorkflow"},"myWorkflow":{"workflowId":"workflow//input.js//myWorkflow"}}}}*/;+/**__internal_workflows{"workflows":{"input.js":{"arrowWorkflow":{"workflowId":"workflow//input.js//arrowWorkflow"},"defaultWorkflow":{"workflowId":"workflow//input.js//defaultWorkflow"},"internalWorkflow":{"workflowId":"workflow//input.js//internalWorkflow"},"myWorkflow":{"workflowId":"workflow//input.js//myWorkflow"}}}}*/;
export async function myWorkflow() {
throw new Error("You attempted to execute workflow myWorkflow function directly. To start a workflow, use start(myWorkflow) from workflow/api");
}
diff --git a/packages/swc-plugin-workflow/transform/tests/fixture/workflow-client-property/output-workflow.js b/packages/swc-plugin-workflow/transform/tests/fixture/workflow-client-property/output-workflow.js
index 9a8dd4c..27047e0 100644
--- a/packages/swc-plugin-workflow/transform/tests/fixture/workflow-client-property/output-workflow.js+++ b/packages/swc-plugin-workflow/transform/tests/fixture/workflow-client-property/output-workflow.js@@ -1,5 +1,5 @@
// Test workflow functions in client mode
-/**__internal_workflows{"workflows":{"input.js":{"arrowWorkflow":{"workflowId":"workflow//input.js//arrowWorkflow"},"default":{"workflowId":"workflow//input.js//default"},"internalWorkflow":{"workflowId":"workflow//input.js//internalWorkflow"},"myWorkflow":{"workflowId":"workflow//input.js//myWorkflow"}}}}*/;+/**__internal_workflows{"workflows":{"input.js":{"arrowWorkflow":{"workflowId":"workflow//input.js//arrowWorkflow"},"defaultWorkflow":{"workflowId":"workflow//input.js//defaultWorkflow"},"internalWorkflow":{"workflowId":"workflow//input.js//internalWorkflow"},"myWorkflow":{"workflowId":"workflow//input.js//myWorkflow"}}}}*/;
export async function myWorkflow() {
const result = await someStep();
return result;

Analysis

Inconsistent metadata keys for named default export workflows

What fails: For named default exports like export default async function defaultWorkflow(), the metadata comment uses the export name "default" as the key while the actual function property is set with the function name "defaultWorkflow", creating an inconsistency.

How to reproduce:

// input.jsexportdefaultasyncfunctiondefaultWorkflow(){'use workflow';returnawaitprocess();}

Run the SWC plugin in client mode on this file.

Result before fix:

  • Metadata comment key: "default":{"workflowId":"workflow//input.js//default"}
  • Actual function property: defaultWorkflow.workflowId = "workflow//input.js//defaultWorkflow"

The metadata key doesn't match the actual function name.

Result after fix:

  • Metadata comment key: "defaultWorkflow":{"workflowId":"workflow//input.js//defaultWorkflow"}
  • Actual function property: defaultWorkflow.workflowId = "workflow//input.js//defaultWorkflow"

Now they are consistent - the metadata key and the function property both reference the actual function name.

Why this matters: The metadata is used to map workflow identifiers to their implementations. When the metadata key doesn't match the actual function name, consumers of this metadata need special logic to handle default exports. By normalizing the metadata to use the actual function name for named default exports (while preserving "default" for truly anonymous exports), the metadata becomes consistent and easier to consume.

@pranaygp

pranaygp commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

looks like e2e tests are failing @TooTallNate

ohh turborepo related? https://github.com/vercel/workflow/actions/runs/19868199087/job/56936552363?pr=484

@TooTallNate
TooTallNateforce-pushed the 12-02-normalize_anonymous_default_export_workflow_ids_to_default_ branch from f2f6418 to 0346122CompareDecember 2, 2025 18:36
@TooTallNate
TooTallNate merged commit 555d7a6 into mainDec 2, 2025
69 of 70 checks passed
@TooTallNate
TooTallNate deleted the 12-02-normalize_anonymous_default_export_workflow_ids_to_default_ branch December 2, 2025 19:26
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@TooTallNate@pranaygp