[swc-plugin] Preserve imports referenced by hoisted nested steps - #1944

Merged
TooTallNate merged 3 commits into
mainfrom
swc-plugin/preserve-imports-for-hoisted-steps
May 5, 2026
Merged

[swc-plugin] Preserve imports referenced by hoisted nested steps#1944
TooTallNate merged 3 commits into
mainfrom
swc-plugin/preserve-imports-for-hoisted-steps

Conversation

@TooTallNate

Copy link
Copy Markdown
Member

Summary

Fixes a bug in the SWC plugin where step-mode bundles dropped module-level imports that were referenced by step functions hoisted out of workflow bodies, causing a ReferenceError at runtime.

Root Cause

Ordering bug in the transform pipeline:

  1. StepTransform::visit_mut_module_items runs and, at the end, invokes remove_dead_code, which strips any import not referenced by current top-level code.
  2. StepTransform::visit_mut_program then hoists nested step functions out of workflow bodies onto the module top level (e.g. var _anonymousStep0 = async (input) => db.query(input.query);).
  3. The hoisted body references db, but the import was already deleted in step 1.

This only affected steps nested inside workflow function bodies — top-level steps already worked because their bodies were inlined in items before DCE ran. Three pre-existing fixtures (nested-step-with-closure, nested-steps-in-object-constructor, factory-with-step-method) had committed buggy outputs that this change corrects.

For example, given:

import{db}from'./db';asyncfunctionw(){'use workflow';constagent=newWorkflowAgent({tools: ()=>({queryDatabase: tool({execute: async(input)=>{'use step';returndb.query(input.query);},}),}),});}

The previous step-mode output omitted import { db } from './db'; while still emitting var _anonymousStep0 = async (input) => db.query(input.query);.

Fix

In packages/swc-plugin-workflow/transform/src/lib.rs:

  • Removed the early remove_dead_code call from the end of visit_mut_module_items.
  • Added a single remove_dead_code(&mut module.body) call in visit_mut_program, after nested step hoisting completes (right before metadata-comment insertion).

Verification

  • Added regression fixture tests/fixture/nested-step-references-module-import/ covering both kept-imports (used by hoisted step) and stripped-imports (truly unused, or only used by replaced workflow body).
  • All 124 SWC fixture tests pass.
  • Three pre-existing fixtures had their output-step.js files updated to now correctly include the imports their hoisted steps reference.
  • spec.md already documented the desired behavior — no spec change needed; this is purely an implementation conformance fix.

Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
CopilotAI review requested due to automatic review settings May 5, 2026 20:21
@vercel

vercelBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

@changeset-bot

changeset-botBot commented May 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9d132e5

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

This PR includes changesets to release 19 packages
NameType
@workflow/swc-pluginPatch
@workflow/astroPatch
@workflow/buildersPatch
@workflow/cliPatch
@workflow/nestPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
tarballsPatch
workflowPatch
@workflow/vitePatch
@workflow/vitestPatch
@workflow/world-testingPatch
@workflow/nuxtPatch
@workflow/aiPatch
@workflow/corePatch
@workflow/web-sharedPatch
@workflow/webPatch

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

@github-actions

github-actionsBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production120002191419
✅ 💻 Local Development158702191806
✅ 📦 Local Production158702191806
✅ 🐘 Local Postgres158702191806
✅ 🪟 Windows12900129
✅ 📋 Other7270176903
Total6817010527869

Details by Category

✅ ▲ Vercel Production
AppPassedFailedSkipped
✅ astro103026
✅ example103026
✅ express103026
✅ fastify103026
✅ hono103026
✅ nextjs-turbopack12702
✅ nextjs-webpack12702
✅ nitro103026
✅ nuxt103026
✅ sveltekit12207
✅ vite103026
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack12900
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable104025
✅ e2e-local-dev-tanstack-start-104025
✅ e2e-local-postgres-nest-stable104025
✅ e2e-local-postgres-tanstack-start-104025
✅ e2e-local-prod-nest-stable104025
✅ e2e-local-prod-tanstack-start-104025
✅ e2e-vercel-prod-tanstack-start103026

📋 View full workflow run

@github-actions

github-actionsBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

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

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.033s (-22.7% 🟢)1.005s (~)0.972s101.00x
💻 LocalExpress0.036s (-19.2% 🟢)1.006s (~)0.970s101.08x
🐘 PostgresExpress0.045s (-21.7% 🟢)1.011s (~)0.965s101.36x
💻 LocalNext.js (Turbopack)0.049s1.005s0.956s101.47x
🐘 PostgresNitro0.051s (-47.0% 🟢)1.011s (-3.1%)0.961s101.52x
🌐 RedisNext.js (Turbopack)0.052s1.005s0.953s101.56x
🐘 PostgresNext.js (Turbopack)0.057s1.011s0.954s101.71x
🌐 MongoDBNext.js (Turbopack)0.129s1.007s0.879s103.86x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro0.220s (-46.4% 🟢)2.151s (-14.3% 🟢)1.931s101.00x
▲ VercelNext.js (Turbopack)1.154s (+359.0% 🔺)2.852s (+22.3% 🔺)1.698s105.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Express1.075s (-4.5%)2.007s (~)0.931s101.00x
💻 LocalNitro1.075s (-5.0%)2.006s (~)0.931s101.00x
🐘 PostgresNitro1.083s (-5.0%)2.009s (~)0.926s101.01x
🐘 PostgresExpress1.084s (-5.4% 🟢)2.009s (~)0.925s101.01x
💻 LocalNext.js (Turbopack)1.110s2.006s0.896s101.03x
🌐 RedisNext.js (Turbopack)1.111s2.006s0.895s101.03x
🐘 PostgresNext.js (Turbopack)1.129s2.008s0.879s101.05x
🌐 MongoDBNext.js (Turbopack)1.169s2.009s0.840s101.09x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro1.608s (-58.7% 🟢)3.463s (-41.4% 🟢)1.855s101.00x
▲ VercelNext.js (Turbopack)3.023s (+48.6% 🔺)4.583s (+19.6% 🔺)1.560s101.88x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro10.404s (-4.9%)11.023s (~)0.618s31.00x
🐘 PostgresExpress10.408s (-5.1% 🟢)11.018s (~)0.611s31.00x
🐘 PostgresNitro10.419s (-4.2%)11.016s (~)0.597s31.00x
💻 LocalExpress10.424s (-4.6%)11.022s (~)0.598s31.00x
🐘 PostgresNext.js (Turbopack)10.657s11.016s0.359s31.02x
💻 LocalNext.js (Turbopack)10.669s11.021s0.353s31.03x
🌐 RedisNext.js (Turbopack)10.691s11.022s0.332s31.03x
🌐 MongoDBNext.js (Turbopack)10.894s11.352s0.458s31.05x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro13.342s (-43.8% 🟢)14.917s (-40.6% 🟢)1.575s31.00x
▲ VercelNext.js (Turbopack)13.784s (-20.4% 🟢)15.604s (-19.6% 🟢)1.821s21.03x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express13.447s (-7.8% 🟢)14.017s (-6.7% 🟢)0.570s51.00x
🐘 PostgresNitro13.451s (-7.8% 🟢)14.015s (-6.7% 🟢)0.565s51.00x
💻 LocalNitro13.507s (-10.3% 🟢)14.027s (-12.5% 🟢)0.520s51.00x
💻 LocalExpress13.523s (-9.7% 🟢)14.028s (-6.7% 🟢)0.505s51.01x
💻 LocalNext.js (Turbopack)14.061s14.828s0.767s51.05x
🌐 RedisNext.js (Turbopack)14.100s15.029s0.929s41.05x
🐘 PostgresNext.js (Turbopack)14.112s15.017s0.905s41.05x
🌐 MongoDBNext.js (Turbopack)14.354s15.026s0.672s41.07x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro21.643s (-66.4% 🟢)23.304s (-65.0% 🟢)1.660s31.00x
▲ VercelNext.js (Turbopack)23.990s (-54.4% 🟢)25.981s (-52.4% 🟢)1.991s31.11x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express11.854s (-15.4% 🟢)12.015s (-17.7% 🟢)0.161s81.00x
💻 LocalNitro11.930s (-28.9% 🟢)12.022s (-29.4% 🟢)0.092s81.01x
🐘 PostgresNitro11.936s (-14.5% 🟢)12.266s (-14.3% 🟢)0.330s81.01x
💻 LocalExpress12.068s (-27.3% 🟢)12.774s (-25.0% 🟢)0.706s81.02x
🌐 RedisNext.js (Turbopack)12.966s13.310s0.344s71.09x
💻 LocalNext.js (Turbopack)13.010s13.167s0.157s71.10x
🐘 PostgresNext.js (Turbopack)13.305s14.016s0.710s71.12x
🌐 MongoDBNext.js (Turbopack)13.338s14.023s0.684s71.13x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro32.625s (-92.3% 🟢)34.494s (-91.9% 🟢)1.869s31.00x
▲ VercelNext.js (Turbopack)35.758s (-90.9% 🟢)37.455s (-90.5% 🟢)1.697s31.10x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.146s (-10.1% 🟢)2.007s (~)0.861s151.00x
🐘 PostgresExpress1.149s (-8.8% 🟢)2.007s (~)0.857s151.00x
💻 LocalNitro1.186s (-27.3% 🟢)2.006s (-3.3%)0.820s151.04x
💻 LocalExpress1.195s (-19.7% 🟢)2.006s (~)0.811s151.04x
🐘 PostgresNext.js (Turbopack)1.235s2.007s0.772s151.08x
🌐 RedisNext.js (Turbopack)1.254s2.006s0.752s151.09x
💻 LocalNext.js (Turbopack)1.292s2.006s0.714s151.13x
🌐 MongoDBNext.js (Turbopack)2.028s2.735s0.707s111.77x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.906s (+3.1%)4.524s (+4.7%)1.618s71.00x
▲ VercelNext.js (Turbopack)4.911s (+44.6% 🔺)6.214s (+26.0% 🔺)1.303s51.69x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.219s (-48.4% 🟢)2.008s (-33.3% 🟢)0.789s151.00x
🐘 PostgresNitro1.230s (-47.7% 🟢)2.007s (-33.3% 🟢)0.777s151.01x
🐘 PostgresNext.js (Turbopack)1.355s2.007s0.652s151.11x
💻 LocalNitro1.777s (-43.5% 🟢)2.006s (-48.4% 🟢)0.228s151.46x
💻 LocalNext.js (Turbopack)1.824s2.006s0.183s151.50x
💻 LocalExpress1.879s (-36.4% 🟢)2.223s (-35.6% 🟢)0.344s141.54x
🌐 RedisNext.js (Turbopack)2.358s3.008s0.650s101.93x
🌐 MongoDBNext.js (Turbopack)3.576s4.009s0.433s82.93x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.582s (-11.6% 🟢)5.158s (-12.9% 🟢)1.577s71.00x
▲ VercelNext.js (Turbopack)5.608s (-21.0% 🟢)7.256s (-18.5% 🟢)1.648s51.57x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.367s (-60.8% 🟢)2.007s (-49.9% 🟢)0.640s151.00x
🐘 PostgresNitro1.376s (-60.5% 🟢)2.007s (-49.9% 🟢)0.632s151.01x
🐘 PostgresNext.js (Turbopack)1.639s2.074s0.435s151.20x
🌐 RedisNext.js (Turbopack)3.586s4.010s0.423s82.62x
💻 LocalNitro5.274s (-36.8% 🟢)5.846s (-35.2% 🟢)0.572s63.86x
💻 LocalExpress5.587s (-33.0% 🟢)6.213s (-31.2% 🟢)0.626s54.09x
💻 LocalNext.js (Turbopack)5.748s6.213s0.465s54.20x
🌐 MongoDBNext.js (Turbopack)6.301s7.013s0.712s54.61x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.978s (+69.6% 🔺)8.125s (+46.8% 🔺)2.147s41.00x
▲ VercelNext.js (Turbopack)7.377s (-17.3% 🟢)9.561s (-12.8% 🟢)2.184s41.23x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.150s (-8.5% 🟢)2.008s (~)0.858s151.00x
🐘 PostgresNitro1.169s (-7.0% 🟢)2.008s (~)0.839s151.02x
🐘 PostgresNext.js (Turbopack)1.218s2.008s0.790s151.06x
🌐 RedisNext.js (Turbopack)1.240s2.006s0.766s151.08x
💻 LocalNext.js (Turbopack)1.322s2.006s0.684s151.15x
💻 LocalNitro1.398s (-25.1% 🟢)2.006s (-14.3% 🟢)0.608s151.22x
💻 LocalExpress1.423s (-24.8% 🟢)2.006s (-15.1% 🟢)0.583s151.24x
🌐 MongoDBNext.js (Turbopack)2.029s2.675s0.645s121.76x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.689s (+9.3% 🔺)4.494s (+7.8% 🔺)1.805s71.00x
▲ VercelNext.js (Turbopack)3.798s (+29.5% 🔺)5.672s (+22.2% 🔺)1.874s61.41x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.229s (-47.5% 🟢)2.008s (-33.3% 🟢)0.779s151.00x
🐘 PostgresNitro1.247s (-46.7% 🟢)2.008s (-33.3% 🟢)0.760s151.02x
🐘 PostgresNext.js (Turbopack)1.386s2.008s0.622s151.13x
💻 LocalExpress2.079s (-33.6% 🟢)2.510s (-33.3% 🟢)0.430s121.69x
💻 LocalNext.js (Turbopack)2.117s2.735s0.617s111.72x
💻 LocalNitro2.169s (-29.2% 🟢)2.593s (-33.3% 🟢)0.424s121.77x
🌐 RedisNext.js (Turbopack)2.343s3.008s0.665s101.91x
🌐 MongoDBNext.js (Turbopack)3.579s4.009s0.430s82.91x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.315s (+2.5%)4.910s (-3.3%)1.595s71.00x
▲ VercelNext.js (Turbopack)5.136s (+63.4% 🔺)7.036s (+55.6% 🔺)1.901s51.55x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.377s (-60.4% 🟢)2.007s (-49.9% 🟢)0.630s151.00x
🐘 PostgresExpress1.386s (-60.4% 🟢)2.008s (-49.9% 🟢)0.622s151.01x
🐘 PostgresNext.js (Turbopack)1.637s2.007s0.370s151.19x
🌐 RedisNext.js (Turbopack)3.635s4.009s0.374s82.64x
💻 LocalNitro5.492s (-39.9% 🟢)6.214s (-38.0% 🟢)0.722s53.99x
💻 LocalNext.js (Turbopack)5.810s6.413s0.603s54.22x
💻 LocalExpress5.859s (-33.4% 🟢)6.616s (-28.7% 🟢)0.757s54.25x
🌐 MongoDBNext.js (Turbopack)6.297s7.013s0.716s54.57x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)6.088s (-9.9% 🟢)8.239s (-3.6%)2.151s41.00x
▲ VercelNitro6.546s (+28.5% 🔺)8.394s (+23.1% 🔺)1.849s41.08x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

workflow with 10 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.440s (-46.4% 🟢)1.006s (~)0.566s601.00x
🐘 PostgresExpress0.454s (-45.8% 🟢)1.006s (-1.7%)0.552s601.03x
💻 LocalExpress0.504s (-48.8% 🟢)1.005s (-6.6% 🟢)0.500s601.15x
💻 LocalNitro0.524s (-46.5% 🟢)1.022s (-6.6% 🟢)0.498s591.19x
🌐 RedisNext.js (Turbopack)0.617s1.004s0.388s601.40x
🐘 PostgresNext.js (Turbopack)0.665s1.006s0.341s601.51x
💻 LocalNext.js (Turbopack)0.726s1.004s0.278s601.65x
🌐 MongoDBNext.js (Turbopack)0.744s1.006s0.262s601.69x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.295s (-76.0% 🟢)7.121s (-70.4% 🟢)1.826s91.00x
▲ VercelNext.js (Turbopack)6.625s (-54.3% 🟢)8.457s (-47.4% 🟢)1.832s81.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.015s (-47.4% 🟢)1.532s (-27.1% 🟢)0.518s591.00x
🐘 PostgresExpress1.052s (-46.8% 🟢)1.632s (-27.7% 🟢)0.580s561.04x
💻 LocalNitro1.204s (-60.3% 🟢)2.006s (-46.6% 🟢)0.801s451.19x
💻 LocalExpress1.286s (-57.4% 🟢)2.006s (-44.0% 🟢)0.720s451.27x
🌐 RedisNext.js (Turbopack)1.476s2.006s0.529s451.46x
🐘 PostgresNext.js (Turbopack)1.585s2.007s0.423s451.56x
💻 LocalNext.js (Turbopack)1.764s2.006s0.241s451.74x
🌐 MongoDBNext.js (Turbopack)1.840s2.007s0.168s451.81x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro12.861s (-67.4% 🟢)14.586s (-64.7% 🟢)1.725s71.00x
▲ VercelNext.js (Turbopack)16.086s (-67.7% 🟢)18.350s (-64.5% 🟢)2.264s51.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 50 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro2.063s (-49.7% 🟢)2.549s (-44.6% 🟢)0.486s481.00x
🐘 PostgresExpress2.126s (-46.7% 🟢)2.719s (-37.8% 🟢)0.592s451.03x
💻 LocalNitro2.678s (-71.2% 🟢)3.008s (-70.0% 🟢)0.330s401.30x
💻 LocalExpress2.803s (-69.6% 🟢)3.033s (-69.7% 🟢)0.230s401.36x
🌐 RedisNext.js (Turbopack)2.963s3.135s0.173s391.44x
🐘 PostgresNext.js (Turbopack)3.131s4.008s0.877s301.52x
💻 LocalNext.js (Turbopack)3.767s4.007s0.240s301.83x
🌐 MongoDBNext.js (Turbopack)4.174s5.012s0.838s242.02x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro40.280s (-58.4% 🟢)42.530s (-56.8% 🟢)2.250s31.00x
▲ VercelNext.js (Turbopack)46.873s (-56.3% 🟢)48.931s (-55.1% 🟢)2.058s31.16x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 10 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.187s (-33.9% 🟢)1.006s (~)0.818s601.00x
🐘 PostgresExpress0.190s (-32.8% 🟢)1.006s (~)0.816s601.01x
🐘 PostgresNext.js (Turbopack)0.236s1.006s0.770s601.26x
🌐 RedisNext.js (Turbopack)0.242s1.004s0.762s601.30x
💻 LocalNitro0.469s (-22.5% 🟢)1.021s (~)0.553s592.50x
💻 LocalExpress0.483s (-13.8% 🟢)1.005s (~)0.522s602.58x
💻 LocalNext.js (Turbopack)0.554s1.005s0.451s602.96x
🌐 MongoDBNext.js (Turbopack)1.030s1.825s0.794s335.50x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.619s (+57.7% 🔺)4.178s (+24.7% 🔺)1.559s151.00x
▲ VercelNext.js (Turbopack)3.871s (+91.4% 🔺)5.504s (+45.1% 🔺)1.633s121.48x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.315s (-36.6% 🟢)1.006s (~)0.691s901.00x
🐘 PostgresExpress0.325s (-36.3% 🟢)1.007s (~)0.682s901.03x
🌐 RedisNext.js (Turbopack)0.410s1.004s0.594s901.30x
🐘 PostgresNext.js (Turbopack)0.458s1.006s0.548s901.45x
💻 LocalNitro2.270s (-10.6% 🟢)2.944s (-2.2%)0.675s317.21x
💻 LocalExpress2.282s (-9.2% 🟢)3.009s (~)0.727s307.25x
💻 LocalNext.js (Turbopack)2.466s3.042s0.576s307.84x
🌐 MongoDBNext.js (Turbopack)2.605s3.007s0.402s308.28x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)8.211s (+132.3% 🔺)9.775s (+88.2% 🔺)1.564s101.00x
▲ VercelNitro9.758s (+202.5% 🔺)11.351s (+135.4% 🔺)1.593s81.19x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

workflow with 50 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.652s (-17.5% 🟢)1.006s (~)0.354s1201.00x
🐘 PostgresExpress0.697s (-14.9% 🟢)1.007s (-1.0%)0.310s1201.07x
🌐 RedisNext.js (Turbopack)0.755s1.004s0.249s1201.16x
🐘 PostgresNext.js (Turbopack)0.944s1.340s0.397s901.45x
🌐 MongoDBNext.js (Turbopack)5.389s6.013s0.624s208.27x
💻 LocalNitro10.289s (-8.1% 🟢)10.781s (-7.6% 🟢)0.492s1215.78x
💻 LocalExpress11.054s (-1.2%)11.668s (-2.3%)0.615s1116.96x
💻 LocalNext.js (Turbopack)11.576s12.233s0.657s1017.76x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)19.155s (+85.5% 🔺)21.092s (+71.7% 🔺)1.938s61.00x
▲ VercelNitro23.620s (+205.8% 🔺)25.372s (+169.9% 🔺)1.753s51.23x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.133s (+452.2% 🔺)1.997s (+100.0% 🔺)0.001s (-18.8% 🟢)2.011s (+98.8% 🔺)0.878s101.00x
🐘 PostgresNitro1.140s (+456.1% 🔺)1.997s (+99.8% 🔺)0.001s (-13.3% 🟢)2.011s (+98.8% 🔺)0.871s101.01x
💻 LocalNitro1.141s (+434.1% 🔺)2.005s (+99.6% 🔺)0.013s (+1.6%)2.021s (+98.3% 🔺)0.879s101.01x
💻 LocalExpress1.142s (+473.8% 🔺)2.006s (+99.7% 🔺)0.013s (+4.1%)2.021s (+98.5% 🔺)0.878s101.01x
💻 LocalNext.js (Turbopack)1.176s2.004s0.012s2.020s0.844s101.04x
🐘 PostgresNext.js (Turbopack)1.196s2.001s0.002s2.011s0.816s101.06x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.149s (-43.9% 🟢)3.058s (-42.1% 🟢)1.931s (+160.2% 🔺)5.669s (-12.6% 🟢)3.520s101.00x
▲ VercelNext.js (Turbopack)4.815s (-29.7% 🟢)5.037s (-41.8% 🟢)0.879s (+39.1% 🔺)7.516s (-23.2% 🟢)2.701s102.24x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

stream pipeline with 5 transform steps (1MB)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.522s (+143.9% 🔺)1.999s (+98.6% 🔺)0.004s (-9.7% 🟢)2.025s (+98.1% 🔺)0.503s301.00x
🐘 PostgresExpress1.563s (+148.0% 🔺)2.005s (+99.2% 🔺)0.004s (-4.3%)2.025s (+98.0% 🔺)0.463s301.03x
💻 LocalNext.js (Turbopack)1.664s2.010s0.009s2.023s0.359s301.09x
🐘 PostgresNext.js (Turbopack)1.669s2.009s0.004s2.024s0.355s301.10x
💻 LocalNitro1.705s (+103.2% 🔺)2.011s (+98.7% 🔺)0.009s (-7.0% 🟢)2.201s (+97.2% 🔺)0.496s281.12x
💻 LocalExpress1.755s (+131.8% 🔺)2.012s (+95.6% 🔺)0.011s (+14.6% 🔺)2.204s (+112.0% 🔺)0.449s281.15x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.949s (-79.8% 🟢)7.135s (-76.8% 🟢)0.212s (+89.2% 🔺)7.803s (-75.4% 🟢)1.855s81.00x
▲ VercelNext.js (Turbopack)12.421s (-26.6% 🟢)12.915s (-29.2% 🟢)0.180s (-14.7% 🟢)14.203s (-25.0% 🟢)1.782s52.09x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

10 parallel streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.674s (-30.4% 🟢)1.050s (-15.9% 🟢)0.000s (-15.8% 🟢)1.064s (-15.4% 🟢)0.390s571.00x
🐘 PostgresExpress0.714s (-25.7% 🟢)1.031s (-19.3% 🟢)0.000s (-100.0% 🟢)1.043s (-20.1% 🟢)0.329s581.06x
🐘 PostgresNext.js (Turbopack)0.787s1.035s0.000s1.049s0.262s581.17x
💻 LocalNitro1.303s (+6.6% 🔺)2.015s (~)0.000s (+166.7% 🔺)2.017s (~)0.714s301.93x
💻 LocalExpress1.426s (+16.4% 🔺)2.015s (~)0.000s (-20.0% 🟢)2.018s (~)0.591s302.11x
💻 LocalNext.js (Turbopack)1.611s2.014s0.000s2.197s0.586s282.39x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.728s (+22.2% 🔺)4.649s (+5.8% 🔺)0.001s (+766.7% 🔺)5.068s (+5.4% 🔺)1.340s121.00x
▲ VercelNext.js (Turbopack)7.287s (-28.4% 🟢)7.260s (-37.0% 🟢)0.000s (NaN%)9.165s (-23.9% 🟢)1.878s71.95x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

fan-out fan-in 10 streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.383s (-22.8% 🟢)2.141s (~)0.000s (+100.0% 🔺)2.153s (-1.0%)0.770s281.00x
🐘 PostgresExpress1.504s (-15.1% 🟢)2.097s (-3.7%)0.000s (NaN%)2.131s (-3.1%)0.627s291.09x
🐘 PostgresNext.js (Turbopack)1.667s2.224s0.000s2.233s0.566s271.21x
💻 LocalNext.js (Turbopack)2.804s3.361s0.000s3.365s0.561s182.03x
💻 LocalNitro3.108s (-8.2% 🟢)3.841s (-4.7%)0.000s (-18.0% 🟢)3.843s (-4.8%)0.735s162.25x
💻 LocalExpress3.249s (-6.3% 🟢)3.842s (-4.7%)0.001s (-21.9% 🟢)3.845s (-4.7%)0.596s162.35x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.969s (+45.8% 🔺)7.219s (+34.3% 🔺)0.000s (-100.0% 🟢)7.627s (+31.6% 🔺)1.658s81.00x
▲ VercelNext.js (Turbopack)9.307s (+65.7% 🔺)9.811s (+40.5% 🔺)0.001s (+300.0% 🔺)11.072s (+46.8% 🔺)1.765s61.56x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro15/21
🐘 PostgresNitro12/21
▲ VercelNitro18/21
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express🐘 Postgres19/21
Next.js (Turbopack)🐘 Postgres10/21
Nitro🐘 Postgres17/21
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)
  • Slurp: Time from first byte to complete stream consumption (stream benchmarks only)
  • Wall Time: Total testbench time (trigger workflow + poll for result)
  • Overhead: Testbench overhead (Wall Time - Workflow Time)
  • Samples: Number of benchmark iterations run
  • vs Fastest: How much slower compared to the fastest configuration for this benchmark

Worlds:

  • 💻 Local: In-memory filesystem world (local development)
  • 🐘 Postgres: PostgreSQL database world (local development)
  • ▲ Vercel: Vercel production/preview deployment
  • 🌐 Turso: Community world (local development)
  • 🌐 MongoDB: Community world (local development)
  • 🌐 Redis: Community world (local development)
  • 🌐 Jazz: Community world (local development)

📋 View full workflow run


Some benchmark jobs failed:

  • Local: success
  • Postgres: success
  • Vercel: failure

Check the workflow run for details.

@karthikscale3karthikscale3 left a comment

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.

LGTM. Verified it in the SWC playground.

CopilotAI left a comment

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.

Pull request overview

This PR adjusts the SWC workflow transform so dead-code elimination runs after nested step hoisting, with the goal of preserving module imports that hoisted step bodies still reference in step-mode output.

Changes:

  • Moves remove_dead_code from visit_mut_module_items to the end of visit_mut_program.
  • Updates existing step-mode fixtures whose hoisted steps now correctly retain required imports.
  • Adds a regression fixture covering nested steps that reference module-level imports.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
packages/swc-plugin-workflow/transform/tests/fixture/nested-steps-in-object-constructor/output-step.jsUpdates expected step output to retain an import used by a hoisted nested step.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-with-closure/output-step.jsUpdates expected step output to retain an import referenced from hoisted closure-based steps.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/output-workflow.jsAdds workflow-mode regression output for the new nested-import fixture.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/output-step.jsAdds step-mode regression output showing preserved imports for a hoisted nested step.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/input.jsAdds the new regression input covering nested step references to module imports.
packages/swc-plugin-workflow/transform/tests/fixture/factory-with-step-method/output-step.jsUpdates expected step output to retain an import used by a hoisted step method.
packages/swc-plugin-workflow/transform/src/lib.rsDefers dead-code elimination until after nested step hoisting completes.
.changeset/preserve-imports-used-by-hoisted-steps.mdRecords the patch release note for the SWC plugin fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/swc-plugin-workflow/transform/src/lib.rs
…nctions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.

CopilotAI left a comment

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.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/swc-plugin-workflow/transform/src/lib.rs
Comment thread.changeset/preserve-imports-used-by-hoisted-steps.md Outdated
…n shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
@TooTallNate
TooTallNate enabled auto-merge (squash) May 5, 2026 21:34
@TooTallNate
TooTallNate merged commit 1d4f83a into mainMay 5, 2026
113 of 114 checks passed
@TooTallNate
TooTallNate deleted the swc-plugin/preserve-imports-for-hoisted-steps branch May 5, 2026 21:36
github-actionsBot added a commit that referenced this pull request May 5, 2026
* [swc-plugin] Preserve imports referenced by hoisted nested steps
Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
* [swc-plugin] Namespace nested step IDs under non-exported workflow functions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.
* [swc-plugin] Namespace nested step IDs across all workflow declaration shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
Signed-off-by: Nathan Rajlich <n@n8.io>
@github-actions

Copy link
Copy Markdown
Contributor

Backport PR opened against stable: #1946. Merge conflicts were resolved by AI — please review carefully.

TooTallNate added a commit that referenced this pull request May 22, 2026
…) (#1946)
* [swc-plugin] Preserve imports referenced by hoisted nested steps
Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
* [swc-plugin] Namespace nested step IDs under non-exported workflow functions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.
* [swc-plugin] Namespace nested step IDs across all workflow declaration shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
Signed-off-by: Nathan Rajlich <n@n8.io>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Nathan Rajlich <n@n8.io>
@github-actionsgithub-actionsBot mentioned this pull request May 22, 2026
TooTallNate added a commit that referenced this pull request May 22, 2026
The fixture was introduced by the backport of #1935 (#1945) with the
pre-namespacing step ID "step//./input//step" in the __internal_workflows
manifest comment. The subsequent backport of #1944 (#1946) shipped the
namespacing fix in lib.rs but did not update this fixture, since on main
the two PRs landed in the reverse order and #1944's diff already covered
the fixture there.
Update the expected output to match what the plugin now emits:
"step//./input//outer/step" — same value already present in main.
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.

3 participants

@TooTallNate@karthikscale3
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

[swc-plugin] Preserve imports referenced by hoisted nested steps - #1944

Merged
TooTallNate merged 3 commits into
mainfrom
swc-plugin/preserve-imports-for-hoisted-steps
May 5, 2026
Merged

[swc-plugin] Preserve imports referenced by hoisted nested steps#1944
TooTallNate merged 3 commits into
mainfrom
swc-plugin/preserve-imports-for-hoisted-steps

Conversation

@TooTallNate

Copy link
Copy Markdown
Member

Summary

Fixes a bug in the SWC plugin where step-mode bundles dropped module-level imports that were referenced by step functions hoisted out of workflow bodies, causing a ReferenceError at runtime.

Root Cause

Ordering bug in the transform pipeline:

  1. StepTransform::visit_mut_module_items runs and, at the end, invokes remove_dead_code, which strips any import not referenced by current top-level code.
  2. StepTransform::visit_mut_program then hoists nested step functions out of workflow bodies onto the module top level (e.g. var _anonymousStep0 = async (input) => db.query(input.query);).
  3. The hoisted body references db, but the import was already deleted in step 1.

This only affected steps nested inside workflow function bodies — top-level steps already worked because their bodies were inlined in items before DCE ran. Three pre-existing fixtures (nested-step-with-closure, nested-steps-in-object-constructor, factory-with-step-method) had committed buggy outputs that this change corrects.

For example, given:

import{db}from'./db';asyncfunctionw(){'use workflow';constagent=newWorkflowAgent({tools: ()=>({queryDatabase: tool({execute: async(input)=>{'use step';returndb.query(input.query);},}),}),});}

The previous step-mode output omitted import { db } from './db'; while still emitting var _anonymousStep0 = async (input) => db.query(input.query);.

Fix

In packages/swc-plugin-workflow/transform/src/lib.rs:

  • Removed the early remove_dead_code call from the end of visit_mut_module_items.
  • Added a single remove_dead_code(&mut module.body) call in visit_mut_program, after nested step hoisting completes (right before metadata-comment insertion).

Verification

  • Added regression fixture tests/fixture/nested-step-references-module-import/ covering both kept-imports (used by hoisted step) and stripped-imports (truly unused, or only used by replaced workflow body).
  • All 124 SWC fixture tests pass.
  • Three pre-existing fixtures had their output-step.js files updated to now correctly include the imports their hoisted steps reference.
  • spec.md already documented the desired behavior — no spec change needed; this is purely an implementation conformance fix.

Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
CopilotAI review requested due to automatic review settings May 5, 2026 20:21
@vercel

vercelBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

@changeset-bot

changeset-botBot commented May 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9d132e5

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

This PR includes changesets to release 19 packages
NameType
@workflow/swc-pluginPatch
@workflow/astroPatch
@workflow/buildersPatch
@workflow/cliPatch
@workflow/nestPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
tarballsPatch
workflowPatch
@workflow/vitePatch
@workflow/vitestPatch
@workflow/world-testingPatch
@workflow/nuxtPatch
@workflow/aiPatch
@workflow/corePatch
@workflow/web-sharedPatch
@workflow/webPatch

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

@github-actions

github-actionsBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production120002191419
✅ 💻 Local Development158702191806
✅ 📦 Local Production158702191806
✅ 🐘 Local Postgres158702191806
✅ 🪟 Windows12900129
✅ 📋 Other7270176903
Total6817010527869

Details by Category

✅ ▲ Vercel Production
AppPassedFailedSkipped
✅ astro103026
✅ example103026
✅ express103026
✅ fastify103026
✅ hono103026
✅ nextjs-turbopack12702
✅ nextjs-webpack12702
✅ nitro103026
✅ nuxt103026
✅ sveltekit12207
✅ vite103026
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack12900
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable104025
✅ e2e-local-dev-tanstack-start-104025
✅ e2e-local-postgres-nest-stable104025
✅ e2e-local-postgres-tanstack-start-104025
✅ e2e-local-prod-nest-stable104025
✅ e2e-local-prod-tanstack-start-104025
✅ e2e-vercel-prod-tanstack-start103026

📋 View full workflow run

@github-actions

github-actionsBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

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

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.033s (-22.7% 🟢)1.005s (~)0.972s101.00x
💻 LocalExpress0.036s (-19.2% 🟢)1.006s (~)0.970s101.08x
🐘 PostgresExpress0.045s (-21.7% 🟢)1.011s (~)0.965s101.36x
💻 LocalNext.js (Turbopack)0.049s1.005s0.956s101.47x
🐘 PostgresNitro0.051s (-47.0% 🟢)1.011s (-3.1%)0.961s101.52x
🌐 RedisNext.js (Turbopack)0.052s1.005s0.953s101.56x
🐘 PostgresNext.js (Turbopack)0.057s1.011s0.954s101.71x
🌐 MongoDBNext.js (Turbopack)0.129s1.007s0.879s103.86x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro0.220s (-46.4% 🟢)2.151s (-14.3% 🟢)1.931s101.00x
▲ VercelNext.js (Turbopack)1.154s (+359.0% 🔺)2.852s (+22.3% 🔺)1.698s105.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Express1.075s (-4.5%)2.007s (~)0.931s101.00x
💻 LocalNitro1.075s (-5.0%)2.006s (~)0.931s101.00x
🐘 PostgresNitro1.083s (-5.0%)2.009s (~)0.926s101.01x
🐘 PostgresExpress1.084s (-5.4% 🟢)2.009s (~)0.925s101.01x
💻 LocalNext.js (Turbopack)1.110s2.006s0.896s101.03x
🌐 RedisNext.js (Turbopack)1.111s2.006s0.895s101.03x
🐘 PostgresNext.js (Turbopack)1.129s2.008s0.879s101.05x
🌐 MongoDBNext.js (Turbopack)1.169s2.009s0.840s101.09x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro1.608s (-58.7% 🟢)3.463s (-41.4% 🟢)1.855s101.00x
▲ VercelNext.js (Turbopack)3.023s (+48.6% 🔺)4.583s (+19.6% 🔺)1.560s101.88x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro10.404s (-4.9%)11.023s (~)0.618s31.00x
🐘 PostgresExpress10.408s (-5.1% 🟢)11.018s (~)0.611s31.00x
🐘 PostgresNitro10.419s (-4.2%)11.016s (~)0.597s31.00x
💻 LocalExpress10.424s (-4.6%)11.022s (~)0.598s31.00x
🐘 PostgresNext.js (Turbopack)10.657s11.016s0.359s31.02x
💻 LocalNext.js (Turbopack)10.669s11.021s0.353s31.03x
🌐 RedisNext.js (Turbopack)10.691s11.022s0.332s31.03x
🌐 MongoDBNext.js (Turbopack)10.894s11.352s0.458s31.05x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro13.342s (-43.8% 🟢)14.917s (-40.6% 🟢)1.575s31.00x
▲ VercelNext.js (Turbopack)13.784s (-20.4% 🟢)15.604s (-19.6% 🟢)1.821s21.03x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express13.447s (-7.8% 🟢)14.017s (-6.7% 🟢)0.570s51.00x
🐘 PostgresNitro13.451s (-7.8% 🟢)14.015s (-6.7% 🟢)0.565s51.00x
💻 LocalNitro13.507s (-10.3% 🟢)14.027s (-12.5% 🟢)0.520s51.00x
💻 LocalExpress13.523s (-9.7% 🟢)14.028s (-6.7% 🟢)0.505s51.01x
💻 LocalNext.js (Turbopack)14.061s14.828s0.767s51.05x
🌐 RedisNext.js (Turbopack)14.100s15.029s0.929s41.05x
🐘 PostgresNext.js (Turbopack)14.112s15.017s0.905s41.05x
🌐 MongoDBNext.js (Turbopack)14.354s15.026s0.672s41.07x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro21.643s (-66.4% 🟢)23.304s (-65.0% 🟢)1.660s31.00x
▲ VercelNext.js (Turbopack)23.990s (-54.4% 🟢)25.981s (-52.4% 🟢)1.991s31.11x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express11.854s (-15.4% 🟢)12.015s (-17.7% 🟢)0.161s81.00x
💻 LocalNitro11.930s (-28.9% 🟢)12.022s (-29.4% 🟢)0.092s81.01x
🐘 PostgresNitro11.936s (-14.5% 🟢)12.266s (-14.3% 🟢)0.330s81.01x
💻 LocalExpress12.068s (-27.3% 🟢)12.774s (-25.0% 🟢)0.706s81.02x
🌐 RedisNext.js (Turbopack)12.966s13.310s0.344s71.09x
💻 LocalNext.js (Turbopack)13.010s13.167s0.157s71.10x
🐘 PostgresNext.js (Turbopack)13.305s14.016s0.710s71.12x
🌐 MongoDBNext.js (Turbopack)13.338s14.023s0.684s71.13x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro32.625s (-92.3% 🟢)34.494s (-91.9% 🟢)1.869s31.00x
▲ VercelNext.js (Turbopack)35.758s (-90.9% 🟢)37.455s (-90.5% 🟢)1.697s31.10x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.146s (-10.1% 🟢)2.007s (~)0.861s151.00x
🐘 PostgresExpress1.149s (-8.8% 🟢)2.007s (~)0.857s151.00x
💻 LocalNitro1.186s (-27.3% 🟢)2.006s (-3.3%)0.820s151.04x
💻 LocalExpress1.195s (-19.7% 🟢)2.006s (~)0.811s151.04x
🐘 PostgresNext.js (Turbopack)1.235s2.007s0.772s151.08x
🌐 RedisNext.js (Turbopack)1.254s2.006s0.752s151.09x
💻 LocalNext.js (Turbopack)1.292s2.006s0.714s151.13x
🌐 MongoDBNext.js (Turbopack)2.028s2.735s0.707s111.77x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.906s (+3.1%)4.524s (+4.7%)1.618s71.00x
▲ VercelNext.js (Turbopack)4.911s (+44.6% 🔺)6.214s (+26.0% 🔺)1.303s51.69x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.219s (-48.4% 🟢)2.008s (-33.3% 🟢)0.789s151.00x
🐘 PostgresNitro1.230s (-47.7% 🟢)2.007s (-33.3% 🟢)0.777s151.01x
🐘 PostgresNext.js (Turbopack)1.355s2.007s0.652s151.11x
💻 LocalNitro1.777s (-43.5% 🟢)2.006s (-48.4% 🟢)0.228s151.46x
💻 LocalNext.js (Turbopack)1.824s2.006s0.183s151.50x
💻 LocalExpress1.879s (-36.4% 🟢)2.223s (-35.6% 🟢)0.344s141.54x
🌐 RedisNext.js (Turbopack)2.358s3.008s0.650s101.93x
🌐 MongoDBNext.js (Turbopack)3.576s4.009s0.433s82.93x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.582s (-11.6% 🟢)5.158s (-12.9% 🟢)1.577s71.00x
▲ VercelNext.js (Turbopack)5.608s (-21.0% 🟢)7.256s (-18.5% 🟢)1.648s51.57x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.367s (-60.8% 🟢)2.007s (-49.9% 🟢)0.640s151.00x
🐘 PostgresNitro1.376s (-60.5% 🟢)2.007s (-49.9% 🟢)0.632s151.01x
🐘 PostgresNext.js (Turbopack)1.639s2.074s0.435s151.20x
🌐 RedisNext.js (Turbopack)3.586s4.010s0.423s82.62x
💻 LocalNitro5.274s (-36.8% 🟢)5.846s (-35.2% 🟢)0.572s63.86x
💻 LocalExpress5.587s (-33.0% 🟢)6.213s (-31.2% 🟢)0.626s54.09x
💻 LocalNext.js (Turbopack)5.748s6.213s0.465s54.20x
🌐 MongoDBNext.js (Turbopack)6.301s7.013s0.712s54.61x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.978s (+69.6% 🔺)8.125s (+46.8% 🔺)2.147s41.00x
▲ VercelNext.js (Turbopack)7.377s (-17.3% 🟢)9.561s (-12.8% 🟢)2.184s41.23x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.150s (-8.5% 🟢)2.008s (~)0.858s151.00x
🐘 PostgresNitro1.169s (-7.0% 🟢)2.008s (~)0.839s151.02x
🐘 PostgresNext.js (Turbopack)1.218s2.008s0.790s151.06x
🌐 RedisNext.js (Turbopack)1.240s2.006s0.766s151.08x
💻 LocalNext.js (Turbopack)1.322s2.006s0.684s151.15x
💻 LocalNitro1.398s (-25.1% 🟢)2.006s (-14.3% 🟢)0.608s151.22x
💻 LocalExpress1.423s (-24.8% 🟢)2.006s (-15.1% 🟢)0.583s151.24x
🌐 MongoDBNext.js (Turbopack)2.029s2.675s0.645s121.76x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.689s (+9.3% 🔺)4.494s (+7.8% 🔺)1.805s71.00x
▲ VercelNext.js (Turbopack)3.798s (+29.5% 🔺)5.672s (+22.2% 🔺)1.874s61.41x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.229s (-47.5% 🟢)2.008s (-33.3% 🟢)0.779s151.00x
🐘 PostgresNitro1.247s (-46.7% 🟢)2.008s (-33.3% 🟢)0.760s151.02x
🐘 PostgresNext.js (Turbopack)1.386s2.008s0.622s151.13x
💻 LocalExpress2.079s (-33.6% 🟢)2.510s (-33.3% 🟢)0.430s121.69x
💻 LocalNext.js (Turbopack)2.117s2.735s0.617s111.72x
💻 LocalNitro2.169s (-29.2% 🟢)2.593s (-33.3% 🟢)0.424s121.77x
🌐 RedisNext.js (Turbopack)2.343s3.008s0.665s101.91x
🌐 MongoDBNext.js (Turbopack)3.579s4.009s0.430s82.91x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.315s (+2.5%)4.910s (-3.3%)1.595s71.00x
▲ VercelNext.js (Turbopack)5.136s (+63.4% 🔺)7.036s (+55.6% 🔺)1.901s51.55x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.377s (-60.4% 🟢)2.007s (-49.9% 🟢)0.630s151.00x
🐘 PostgresExpress1.386s (-60.4% 🟢)2.008s (-49.9% 🟢)0.622s151.01x
🐘 PostgresNext.js (Turbopack)1.637s2.007s0.370s151.19x
🌐 RedisNext.js (Turbopack)3.635s4.009s0.374s82.64x
💻 LocalNitro5.492s (-39.9% 🟢)6.214s (-38.0% 🟢)0.722s53.99x
💻 LocalNext.js (Turbopack)5.810s6.413s0.603s54.22x
💻 LocalExpress5.859s (-33.4% 🟢)6.616s (-28.7% 🟢)0.757s54.25x
🌐 MongoDBNext.js (Turbopack)6.297s7.013s0.716s54.57x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)6.088s (-9.9% 🟢)8.239s (-3.6%)2.151s41.00x
▲ VercelNitro6.546s (+28.5% 🔺)8.394s (+23.1% 🔺)1.849s41.08x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

workflow with 10 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.440s (-46.4% 🟢)1.006s (~)0.566s601.00x
🐘 PostgresExpress0.454s (-45.8% 🟢)1.006s (-1.7%)0.552s601.03x
💻 LocalExpress0.504s (-48.8% 🟢)1.005s (-6.6% 🟢)0.500s601.15x
💻 LocalNitro0.524s (-46.5% 🟢)1.022s (-6.6% 🟢)0.498s591.19x
🌐 RedisNext.js (Turbopack)0.617s1.004s0.388s601.40x
🐘 PostgresNext.js (Turbopack)0.665s1.006s0.341s601.51x
💻 LocalNext.js (Turbopack)0.726s1.004s0.278s601.65x
🌐 MongoDBNext.js (Turbopack)0.744s1.006s0.262s601.69x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.295s (-76.0% 🟢)7.121s (-70.4% 🟢)1.826s91.00x
▲ VercelNext.js (Turbopack)6.625s (-54.3% 🟢)8.457s (-47.4% 🟢)1.832s81.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.015s (-47.4% 🟢)1.532s (-27.1% 🟢)0.518s591.00x
🐘 PostgresExpress1.052s (-46.8% 🟢)1.632s (-27.7% 🟢)0.580s561.04x
💻 LocalNitro1.204s (-60.3% 🟢)2.006s (-46.6% 🟢)0.801s451.19x
💻 LocalExpress1.286s (-57.4% 🟢)2.006s (-44.0% 🟢)0.720s451.27x
🌐 RedisNext.js (Turbopack)1.476s2.006s0.529s451.46x
🐘 PostgresNext.js (Turbopack)1.585s2.007s0.423s451.56x
💻 LocalNext.js (Turbopack)1.764s2.006s0.241s451.74x
🌐 MongoDBNext.js (Turbopack)1.840s2.007s0.168s451.81x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro12.861s (-67.4% 🟢)14.586s (-64.7% 🟢)1.725s71.00x
▲ VercelNext.js (Turbopack)16.086s (-67.7% 🟢)18.350s (-64.5% 🟢)2.264s51.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 50 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro2.063s (-49.7% 🟢)2.549s (-44.6% 🟢)0.486s481.00x
🐘 PostgresExpress2.126s (-46.7% 🟢)2.719s (-37.8% 🟢)0.592s451.03x
💻 LocalNitro2.678s (-71.2% 🟢)3.008s (-70.0% 🟢)0.330s401.30x
💻 LocalExpress2.803s (-69.6% 🟢)3.033s (-69.7% 🟢)0.230s401.36x
🌐 RedisNext.js (Turbopack)2.963s3.135s0.173s391.44x
🐘 PostgresNext.js (Turbopack)3.131s4.008s0.877s301.52x
💻 LocalNext.js (Turbopack)3.767s4.007s0.240s301.83x
🌐 MongoDBNext.js (Turbopack)4.174s5.012s0.838s242.02x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro40.280s (-58.4% 🟢)42.530s (-56.8% 🟢)2.250s31.00x
▲ VercelNext.js (Turbopack)46.873s (-56.3% 🟢)48.931s (-55.1% 🟢)2.058s31.16x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 10 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.187s (-33.9% 🟢)1.006s (~)0.818s601.00x
🐘 PostgresExpress0.190s (-32.8% 🟢)1.006s (~)0.816s601.01x
🐘 PostgresNext.js (Turbopack)0.236s1.006s0.770s601.26x
🌐 RedisNext.js (Turbopack)0.242s1.004s0.762s601.30x
💻 LocalNitro0.469s (-22.5% 🟢)1.021s (~)0.553s592.50x
💻 LocalExpress0.483s (-13.8% 🟢)1.005s (~)0.522s602.58x
💻 LocalNext.js (Turbopack)0.554s1.005s0.451s602.96x
🌐 MongoDBNext.js (Turbopack)1.030s1.825s0.794s335.50x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.619s (+57.7% 🔺)4.178s (+24.7% 🔺)1.559s151.00x
▲ VercelNext.js (Turbopack)3.871s (+91.4% 🔺)5.504s (+45.1% 🔺)1.633s121.48x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.315s (-36.6% 🟢)1.006s (~)0.691s901.00x
🐘 PostgresExpress0.325s (-36.3% 🟢)1.007s (~)0.682s901.03x
🌐 RedisNext.js (Turbopack)0.410s1.004s0.594s901.30x
🐘 PostgresNext.js (Turbopack)0.458s1.006s0.548s901.45x
💻 LocalNitro2.270s (-10.6% 🟢)2.944s (-2.2%)0.675s317.21x
💻 LocalExpress2.282s (-9.2% 🟢)3.009s (~)0.727s307.25x
💻 LocalNext.js (Turbopack)2.466s3.042s0.576s307.84x
🌐 MongoDBNext.js (Turbopack)2.605s3.007s0.402s308.28x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)8.211s (+132.3% 🔺)9.775s (+88.2% 🔺)1.564s101.00x
▲ VercelNitro9.758s (+202.5% 🔺)11.351s (+135.4% 🔺)1.593s81.19x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

workflow with 50 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.652s (-17.5% 🟢)1.006s (~)0.354s1201.00x
🐘 PostgresExpress0.697s (-14.9% 🟢)1.007s (-1.0%)0.310s1201.07x
🌐 RedisNext.js (Turbopack)0.755s1.004s0.249s1201.16x
🐘 PostgresNext.js (Turbopack)0.944s1.340s0.397s901.45x
🌐 MongoDBNext.js (Turbopack)5.389s6.013s0.624s208.27x
💻 LocalNitro10.289s (-8.1% 🟢)10.781s (-7.6% 🟢)0.492s1215.78x
💻 LocalExpress11.054s (-1.2%)11.668s (-2.3%)0.615s1116.96x
💻 LocalNext.js (Turbopack)11.576s12.233s0.657s1017.76x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)19.155s (+85.5% 🔺)21.092s (+71.7% 🔺)1.938s61.00x
▲ VercelNitro23.620s (+205.8% 🔺)25.372s (+169.9% 🔺)1.753s51.23x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.133s (+452.2% 🔺)1.997s (+100.0% 🔺)0.001s (-18.8% 🟢)2.011s (+98.8% 🔺)0.878s101.00x
🐘 PostgresNitro1.140s (+456.1% 🔺)1.997s (+99.8% 🔺)0.001s (-13.3% 🟢)2.011s (+98.8% 🔺)0.871s101.01x
💻 LocalNitro1.141s (+434.1% 🔺)2.005s (+99.6% 🔺)0.013s (+1.6%)2.021s (+98.3% 🔺)0.879s101.01x
💻 LocalExpress1.142s (+473.8% 🔺)2.006s (+99.7% 🔺)0.013s (+4.1%)2.021s (+98.5% 🔺)0.878s101.01x
💻 LocalNext.js (Turbopack)1.176s2.004s0.012s2.020s0.844s101.04x
🐘 PostgresNext.js (Turbopack)1.196s2.001s0.002s2.011s0.816s101.06x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.149s (-43.9% 🟢)3.058s (-42.1% 🟢)1.931s (+160.2% 🔺)5.669s (-12.6% 🟢)3.520s101.00x
▲ VercelNext.js (Turbopack)4.815s (-29.7% 🟢)5.037s (-41.8% 🟢)0.879s (+39.1% 🔺)7.516s (-23.2% 🟢)2.701s102.24x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

stream pipeline with 5 transform steps (1MB)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.522s (+143.9% 🔺)1.999s (+98.6% 🔺)0.004s (-9.7% 🟢)2.025s (+98.1% 🔺)0.503s301.00x
🐘 PostgresExpress1.563s (+148.0% 🔺)2.005s (+99.2% 🔺)0.004s (-4.3%)2.025s (+98.0% 🔺)0.463s301.03x
💻 LocalNext.js (Turbopack)1.664s2.010s0.009s2.023s0.359s301.09x
🐘 PostgresNext.js (Turbopack)1.669s2.009s0.004s2.024s0.355s301.10x
💻 LocalNitro1.705s (+103.2% 🔺)2.011s (+98.7% 🔺)0.009s (-7.0% 🟢)2.201s (+97.2% 🔺)0.496s281.12x
💻 LocalExpress1.755s (+131.8% 🔺)2.012s (+95.6% 🔺)0.011s (+14.6% 🔺)2.204s (+112.0% 🔺)0.449s281.15x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.949s (-79.8% 🟢)7.135s (-76.8% 🟢)0.212s (+89.2% 🔺)7.803s (-75.4% 🟢)1.855s81.00x
▲ VercelNext.js (Turbopack)12.421s (-26.6% 🟢)12.915s (-29.2% 🟢)0.180s (-14.7% 🟢)14.203s (-25.0% 🟢)1.782s52.09x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

10 parallel streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.674s (-30.4% 🟢)1.050s (-15.9% 🟢)0.000s (-15.8% 🟢)1.064s (-15.4% 🟢)0.390s571.00x
🐘 PostgresExpress0.714s (-25.7% 🟢)1.031s (-19.3% 🟢)0.000s (-100.0% 🟢)1.043s (-20.1% 🟢)0.329s581.06x
🐘 PostgresNext.js (Turbopack)0.787s1.035s0.000s1.049s0.262s581.17x
💻 LocalNitro1.303s (+6.6% 🔺)2.015s (~)0.000s (+166.7% 🔺)2.017s (~)0.714s301.93x
💻 LocalExpress1.426s (+16.4% 🔺)2.015s (~)0.000s (-20.0% 🟢)2.018s (~)0.591s302.11x
💻 LocalNext.js (Turbopack)1.611s2.014s0.000s2.197s0.586s282.39x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.728s (+22.2% 🔺)4.649s (+5.8% 🔺)0.001s (+766.7% 🔺)5.068s (+5.4% 🔺)1.340s121.00x
▲ VercelNext.js (Turbopack)7.287s (-28.4% 🟢)7.260s (-37.0% 🟢)0.000s (NaN%)9.165s (-23.9% 🟢)1.878s71.95x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

fan-out fan-in 10 streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.383s (-22.8% 🟢)2.141s (~)0.000s (+100.0% 🔺)2.153s (-1.0%)0.770s281.00x
🐘 PostgresExpress1.504s (-15.1% 🟢)2.097s (-3.7%)0.000s (NaN%)2.131s (-3.1%)0.627s291.09x
🐘 PostgresNext.js (Turbopack)1.667s2.224s0.000s2.233s0.566s271.21x
💻 LocalNext.js (Turbopack)2.804s3.361s0.000s3.365s0.561s182.03x
💻 LocalNitro3.108s (-8.2% 🟢)3.841s (-4.7%)0.000s (-18.0% 🟢)3.843s (-4.8%)0.735s162.25x
💻 LocalExpress3.249s (-6.3% 🟢)3.842s (-4.7%)0.001s (-21.9% 🟢)3.845s (-4.7%)0.596s162.35x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.969s (+45.8% 🔺)7.219s (+34.3% 🔺)0.000s (-100.0% 🟢)7.627s (+31.6% 🔺)1.658s81.00x
▲ VercelNext.js (Turbopack)9.307s (+65.7% 🔺)9.811s (+40.5% 🔺)0.001s (+300.0% 🔺)11.072s (+46.8% 🔺)1.765s61.56x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro15/21
🐘 PostgresNitro12/21
▲ VercelNitro18/21
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express🐘 Postgres19/21
Next.js (Turbopack)🐘 Postgres10/21
Nitro🐘 Postgres17/21
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)
  • Slurp: Time from first byte to complete stream consumption (stream benchmarks only)
  • Wall Time: Total testbench time (trigger workflow + poll for result)
  • Overhead: Testbench overhead (Wall Time - Workflow Time)
  • Samples: Number of benchmark iterations run
  • vs Fastest: How much slower compared to the fastest configuration for this benchmark

Worlds:

  • 💻 Local: In-memory filesystem world (local development)
  • 🐘 Postgres: PostgreSQL database world (local development)
  • ▲ Vercel: Vercel production/preview deployment
  • 🌐 Turso: Community world (local development)
  • 🌐 MongoDB: Community world (local development)
  • 🌐 Redis: Community world (local development)
  • 🌐 Jazz: Community world (local development)

📋 View full workflow run


Some benchmark jobs failed:

  • Local: success
  • Postgres: success
  • Vercel: failure

Check the workflow run for details.

@karthikscale3karthikscale3 left a comment

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.

LGTM. Verified it in the SWC playground.

CopilotAI left a comment

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.

Pull request overview

This PR adjusts the SWC workflow transform so dead-code elimination runs after nested step hoisting, with the goal of preserving module imports that hoisted step bodies still reference in step-mode output.

Changes:

  • Moves remove_dead_code from visit_mut_module_items to the end of visit_mut_program.
  • Updates existing step-mode fixtures whose hoisted steps now correctly retain required imports.
  • Adds a regression fixture covering nested steps that reference module-level imports.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
packages/swc-plugin-workflow/transform/tests/fixture/nested-steps-in-object-constructor/output-step.jsUpdates expected step output to retain an import used by a hoisted nested step.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-with-closure/output-step.jsUpdates expected step output to retain an import referenced from hoisted closure-based steps.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/output-workflow.jsAdds workflow-mode regression output for the new nested-import fixture.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/output-step.jsAdds step-mode regression output showing preserved imports for a hoisted nested step.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/input.jsAdds the new regression input covering nested step references to module imports.
packages/swc-plugin-workflow/transform/tests/fixture/factory-with-step-method/output-step.jsUpdates expected step output to retain an import used by a hoisted step method.
packages/swc-plugin-workflow/transform/src/lib.rsDefers dead-code elimination until after nested step hoisting completes.
.changeset/preserve-imports-used-by-hoisted-steps.mdRecords the patch release note for the SWC plugin fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/swc-plugin-workflow/transform/src/lib.rs
…nctions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.

CopilotAI left a comment

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.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/swc-plugin-workflow/transform/src/lib.rs
Comment thread.changeset/preserve-imports-used-by-hoisted-steps.md Outdated
…n shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
@TooTallNate
TooTallNate enabled auto-merge (squash) May 5, 2026 21:34
@TooTallNate
TooTallNate merged commit 1d4f83a into mainMay 5, 2026
113 of 114 checks passed
@TooTallNate
TooTallNate deleted the swc-plugin/preserve-imports-for-hoisted-steps branch May 5, 2026 21:36
github-actionsBot added a commit that referenced this pull request May 5, 2026
* [swc-plugin] Preserve imports referenced by hoisted nested steps
Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
* [swc-plugin] Namespace nested step IDs under non-exported workflow functions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.
* [swc-plugin] Namespace nested step IDs across all workflow declaration shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
Signed-off-by: Nathan Rajlich <n@n8.io>
@github-actions

Copy link
Copy Markdown
Contributor

Backport PR opened against stable: #1946. Merge conflicts were resolved by AI — please review carefully.

TooTallNate added a commit that referenced this pull request May 22, 2026
…) (#1946)
* [swc-plugin] Preserve imports referenced by hoisted nested steps
Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
* [swc-plugin] Namespace nested step IDs under non-exported workflow functions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.
* [swc-plugin] Namespace nested step IDs across all workflow declaration shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
Signed-off-by: Nathan Rajlich <n@n8.io>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Nathan Rajlich <n@n8.io>
@github-actionsgithub-actionsBot mentioned this pull request May 22, 2026
TooTallNate added a commit that referenced this pull request May 22, 2026
The fixture was introduced by the backport of #1935 (#1945) with the
pre-namespacing step ID "step//./input//step" in the __internal_workflows
manifest comment. The subsequent backport of #1944 (#1946) shipped the
namespacing fix in lib.rs but did not update this fixture, since on main
the two PRs landed in the reverse order and #1944's diff already covered
the fixture there.
Update the expected output to match what the plugin now emits:
"step//./input//outer/step" — same value already present in main.
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.

3 participants

@TooTallNate@karthikscale3
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

[swc-plugin] Preserve imports referenced by hoisted nested steps - #1944

Merged
TooTallNate merged 3 commits into
mainfrom
swc-plugin/preserve-imports-for-hoisted-steps
May 5, 2026
Merged

[swc-plugin] Preserve imports referenced by hoisted nested steps#1944
TooTallNate merged 3 commits into
mainfrom
swc-plugin/preserve-imports-for-hoisted-steps

Conversation

@TooTallNate

Copy link
Copy Markdown
Member

Summary

Fixes a bug in the SWC plugin where step-mode bundles dropped module-level imports that were referenced by step functions hoisted out of workflow bodies, causing a ReferenceError at runtime.

Root Cause

Ordering bug in the transform pipeline:

  1. StepTransform::visit_mut_module_items runs and, at the end, invokes remove_dead_code, which strips any import not referenced by current top-level code.
  2. StepTransform::visit_mut_program then hoists nested step functions out of workflow bodies onto the module top level (e.g. var _anonymousStep0 = async (input) => db.query(input.query);).
  3. The hoisted body references db, but the import was already deleted in step 1.

This only affected steps nested inside workflow function bodies — top-level steps already worked because their bodies were inlined in items before DCE ran. Three pre-existing fixtures (nested-step-with-closure, nested-steps-in-object-constructor, factory-with-step-method) had committed buggy outputs that this change corrects.

For example, given:

import{db}from'./db';asyncfunctionw(){'use workflow';constagent=newWorkflowAgent({tools: ()=>({queryDatabase: tool({execute: async(input)=>{'use step';returndb.query(input.query);},}),}),});}

The previous step-mode output omitted import { db } from './db'; while still emitting var _anonymousStep0 = async (input) => db.query(input.query);.

Fix

In packages/swc-plugin-workflow/transform/src/lib.rs:

  • Removed the early remove_dead_code call from the end of visit_mut_module_items.
  • Added a single remove_dead_code(&mut module.body) call in visit_mut_program, after nested step hoisting completes (right before metadata-comment insertion).

Verification

  • Added regression fixture tests/fixture/nested-step-references-module-import/ covering both kept-imports (used by hoisted step) and stripped-imports (truly unused, or only used by replaced workflow body).
  • All 124 SWC fixture tests pass.
  • Three pre-existing fixtures had their output-step.js files updated to now correctly include the imports their hoisted steps reference.
  • spec.md already documented the desired behavior — no spec change needed; this is purely an implementation conformance fix.

Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
CopilotAI review requested due to automatic review settings May 5, 2026 20:21
@vercel

vercelBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

@changeset-bot

changeset-botBot commented May 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9d132e5

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

This PR includes changesets to release 19 packages
NameType
@workflow/swc-pluginPatch
@workflow/astroPatch
@workflow/buildersPatch
@workflow/cliPatch
@workflow/nestPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
tarballsPatch
workflowPatch
@workflow/vitePatch
@workflow/vitestPatch
@workflow/world-testingPatch
@workflow/nuxtPatch
@workflow/aiPatch
@workflow/corePatch
@workflow/web-sharedPatch
@workflow/webPatch

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

@github-actions

github-actionsBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production120002191419
✅ 💻 Local Development158702191806
✅ 📦 Local Production158702191806
✅ 🐘 Local Postgres158702191806
✅ 🪟 Windows12900129
✅ 📋 Other7270176903
Total6817010527869

Details by Category

✅ ▲ Vercel Production
AppPassedFailedSkipped
✅ astro103026
✅ example103026
✅ express103026
✅ fastify103026
✅ hono103026
✅ nextjs-turbopack12702
✅ nextjs-webpack12702
✅ nitro103026
✅ nuxt103026
✅ sveltekit12207
✅ vite103026
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack12900
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable104025
✅ e2e-local-dev-tanstack-start-104025
✅ e2e-local-postgres-nest-stable104025
✅ e2e-local-postgres-tanstack-start-104025
✅ e2e-local-prod-nest-stable104025
✅ e2e-local-prod-tanstack-start-104025
✅ e2e-vercel-prod-tanstack-start103026

📋 View full workflow run

@github-actions

github-actionsBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

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

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.033s (-22.7% 🟢)1.005s (~)0.972s101.00x
💻 LocalExpress0.036s (-19.2% 🟢)1.006s (~)0.970s101.08x
🐘 PostgresExpress0.045s (-21.7% 🟢)1.011s (~)0.965s101.36x
💻 LocalNext.js (Turbopack)0.049s1.005s0.956s101.47x
🐘 PostgresNitro0.051s (-47.0% 🟢)1.011s (-3.1%)0.961s101.52x
🌐 RedisNext.js (Turbopack)0.052s1.005s0.953s101.56x
🐘 PostgresNext.js (Turbopack)0.057s1.011s0.954s101.71x
🌐 MongoDBNext.js (Turbopack)0.129s1.007s0.879s103.86x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro0.220s (-46.4% 🟢)2.151s (-14.3% 🟢)1.931s101.00x
▲ VercelNext.js (Turbopack)1.154s (+359.0% 🔺)2.852s (+22.3% 🔺)1.698s105.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Express1.075s (-4.5%)2.007s (~)0.931s101.00x
💻 LocalNitro1.075s (-5.0%)2.006s (~)0.931s101.00x
🐘 PostgresNitro1.083s (-5.0%)2.009s (~)0.926s101.01x
🐘 PostgresExpress1.084s (-5.4% 🟢)2.009s (~)0.925s101.01x
💻 LocalNext.js (Turbopack)1.110s2.006s0.896s101.03x
🌐 RedisNext.js (Turbopack)1.111s2.006s0.895s101.03x
🐘 PostgresNext.js (Turbopack)1.129s2.008s0.879s101.05x
🌐 MongoDBNext.js (Turbopack)1.169s2.009s0.840s101.09x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro1.608s (-58.7% 🟢)3.463s (-41.4% 🟢)1.855s101.00x
▲ VercelNext.js (Turbopack)3.023s (+48.6% 🔺)4.583s (+19.6% 🔺)1.560s101.88x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro10.404s (-4.9%)11.023s (~)0.618s31.00x
🐘 PostgresExpress10.408s (-5.1% 🟢)11.018s (~)0.611s31.00x
🐘 PostgresNitro10.419s (-4.2%)11.016s (~)0.597s31.00x
💻 LocalExpress10.424s (-4.6%)11.022s (~)0.598s31.00x
🐘 PostgresNext.js (Turbopack)10.657s11.016s0.359s31.02x
💻 LocalNext.js (Turbopack)10.669s11.021s0.353s31.03x
🌐 RedisNext.js (Turbopack)10.691s11.022s0.332s31.03x
🌐 MongoDBNext.js (Turbopack)10.894s11.352s0.458s31.05x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro13.342s (-43.8% 🟢)14.917s (-40.6% 🟢)1.575s31.00x
▲ VercelNext.js (Turbopack)13.784s (-20.4% 🟢)15.604s (-19.6% 🟢)1.821s21.03x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express13.447s (-7.8% 🟢)14.017s (-6.7% 🟢)0.570s51.00x
🐘 PostgresNitro13.451s (-7.8% 🟢)14.015s (-6.7% 🟢)0.565s51.00x
💻 LocalNitro13.507s (-10.3% 🟢)14.027s (-12.5% 🟢)0.520s51.00x
💻 LocalExpress13.523s (-9.7% 🟢)14.028s (-6.7% 🟢)0.505s51.01x
💻 LocalNext.js (Turbopack)14.061s14.828s0.767s51.05x
🌐 RedisNext.js (Turbopack)14.100s15.029s0.929s41.05x
🐘 PostgresNext.js (Turbopack)14.112s15.017s0.905s41.05x
🌐 MongoDBNext.js (Turbopack)14.354s15.026s0.672s41.07x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro21.643s (-66.4% 🟢)23.304s (-65.0% 🟢)1.660s31.00x
▲ VercelNext.js (Turbopack)23.990s (-54.4% 🟢)25.981s (-52.4% 🟢)1.991s31.11x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express11.854s (-15.4% 🟢)12.015s (-17.7% 🟢)0.161s81.00x
💻 LocalNitro11.930s (-28.9% 🟢)12.022s (-29.4% 🟢)0.092s81.01x
🐘 PostgresNitro11.936s (-14.5% 🟢)12.266s (-14.3% 🟢)0.330s81.01x
💻 LocalExpress12.068s (-27.3% 🟢)12.774s (-25.0% 🟢)0.706s81.02x
🌐 RedisNext.js (Turbopack)12.966s13.310s0.344s71.09x
💻 LocalNext.js (Turbopack)13.010s13.167s0.157s71.10x
🐘 PostgresNext.js (Turbopack)13.305s14.016s0.710s71.12x
🌐 MongoDBNext.js (Turbopack)13.338s14.023s0.684s71.13x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro32.625s (-92.3% 🟢)34.494s (-91.9% 🟢)1.869s31.00x
▲ VercelNext.js (Turbopack)35.758s (-90.9% 🟢)37.455s (-90.5% 🟢)1.697s31.10x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.146s (-10.1% 🟢)2.007s (~)0.861s151.00x
🐘 PostgresExpress1.149s (-8.8% 🟢)2.007s (~)0.857s151.00x
💻 LocalNitro1.186s (-27.3% 🟢)2.006s (-3.3%)0.820s151.04x
💻 LocalExpress1.195s (-19.7% 🟢)2.006s (~)0.811s151.04x
🐘 PostgresNext.js (Turbopack)1.235s2.007s0.772s151.08x
🌐 RedisNext.js (Turbopack)1.254s2.006s0.752s151.09x
💻 LocalNext.js (Turbopack)1.292s2.006s0.714s151.13x
🌐 MongoDBNext.js (Turbopack)2.028s2.735s0.707s111.77x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.906s (+3.1%)4.524s (+4.7%)1.618s71.00x
▲ VercelNext.js (Turbopack)4.911s (+44.6% 🔺)6.214s (+26.0% 🔺)1.303s51.69x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.219s (-48.4% 🟢)2.008s (-33.3% 🟢)0.789s151.00x
🐘 PostgresNitro1.230s (-47.7% 🟢)2.007s (-33.3% 🟢)0.777s151.01x
🐘 PostgresNext.js (Turbopack)1.355s2.007s0.652s151.11x
💻 LocalNitro1.777s (-43.5% 🟢)2.006s (-48.4% 🟢)0.228s151.46x
💻 LocalNext.js (Turbopack)1.824s2.006s0.183s151.50x
💻 LocalExpress1.879s (-36.4% 🟢)2.223s (-35.6% 🟢)0.344s141.54x
🌐 RedisNext.js (Turbopack)2.358s3.008s0.650s101.93x
🌐 MongoDBNext.js (Turbopack)3.576s4.009s0.433s82.93x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.582s (-11.6% 🟢)5.158s (-12.9% 🟢)1.577s71.00x
▲ VercelNext.js (Turbopack)5.608s (-21.0% 🟢)7.256s (-18.5% 🟢)1.648s51.57x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.367s (-60.8% 🟢)2.007s (-49.9% 🟢)0.640s151.00x
🐘 PostgresNitro1.376s (-60.5% 🟢)2.007s (-49.9% 🟢)0.632s151.01x
🐘 PostgresNext.js (Turbopack)1.639s2.074s0.435s151.20x
🌐 RedisNext.js (Turbopack)3.586s4.010s0.423s82.62x
💻 LocalNitro5.274s (-36.8% 🟢)5.846s (-35.2% 🟢)0.572s63.86x
💻 LocalExpress5.587s (-33.0% 🟢)6.213s (-31.2% 🟢)0.626s54.09x
💻 LocalNext.js (Turbopack)5.748s6.213s0.465s54.20x
🌐 MongoDBNext.js (Turbopack)6.301s7.013s0.712s54.61x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.978s (+69.6% 🔺)8.125s (+46.8% 🔺)2.147s41.00x
▲ VercelNext.js (Turbopack)7.377s (-17.3% 🟢)9.561s (-12.8% 🟢)2.184s41.23x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.150s (-8.5% 🟢)2.008s (~)0.858s151.00x
🐘 PostgresNitro1.169s (-7.0% 🟢)2.008s (~)0.839s151.02x
🐘 PostgresNext.js (Turbopack)1.218s2.008s0.790s151.06x
🌐 RedisNext.js (Turbopack)1.240s2.006s0.766s151.08x
💻 LocalNext.js (Turbopack)1.322s2.006s0.684s151.15x
💻 LocalNitro1.398s (-25.1% 🟢)2.006s (-14.3% 🟢)0.608s151.22x
💻 LocalExpress1.423s (-24.8% 🟢)2.006s (-15.1% 🟢)0.583s151.24x
🌐 MongoDBNext.js (Turbopack)2.029s2.675s0.645s121.76x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.689s (+9.3% 🔺)4.494s (+7.8% 🔺)1.805s71.00x
▲ VercelNext.js (Turbopack)3.798s (+29.5% 🔺)5.672s (+22.2% 🔺)1.874s61.41x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.229s (-47.5% 🟢)2.008s (-33.3% 🟢)0.779s151.00x
🐘 PostgresNitro1.247s (-46.7% 🟢)2.008s (-33.3% 🟢)0.760s151.02x
🐘 PostgresNext.js (Turbopack)1.386s2.008s0.622s151.13x
💻 LocalExpress2.079s (-33.6% 🟢)2.510s (-33.3% 🟢)0.430s121.69x
💻 LocalNext.js (Turbopack)2.117s2.735s0.617s111.72x
💻 LocalNitro2.169s (-29.2% 🟢)2.593s (-33.3% 🟢)0.424s121.77x
🌐 RedisNext.js (Turbopack)2.343s3.008s0.665s101.91x
🌐 MongoDBNext.js (Turbopack)3.579s4.009s0.430s82.91x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.315s (+2.5%)4.910s (-3.3%)1.595s71.00x
▲ VercelNext.js (Turbopack)5.136s (+63.4% 🔺)7.036s (+55.6% 🔺)1.901s51.55x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.377s (-60.4% 🟢)2.007s (-49.9% 🟢)0.630s151.00x
🐘 PostgresExpress1.386s (-60.4% 🟢)2.008s (-49.9% 🟢)0.622s151.01x
🐘 PostgresNext.js (Turbopack)1.637s2.007s0.370s151.19x
🌐 RedisNext.js (Turbopack)3.635s4.009s0.374s82.64x
💻 LocalNitro5.492s (-39.9% 🟢)6.214s (-38.0% 🟢)0.722s53.99x
💻 LocalNext.js (Turbopack)5.810s6.413s0.603s54.22x
💻 LocalExpress5.859s (-33.4% 🟢)6.616s (-28.7% 🟢)0.757s54.25x
🌐 MongoDBNext.js (Turbopack)6.297s7.013s0.716s54.57x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)6.088s (-9.9% 🟢)8.239s (-3.6%)2.151s41.00x
▲ VercelNitro6.546s (+28.5% 🔺)8.394s (+23.1% 🔺)1.849s41.08x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

workflow with 10 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.440s (-46.4% 🟢)1.006s (~)0.566s601.00x
🐘 PostgresExpress0.454s (-45.8% 🟢)1.006s (-1.7%)0.552s601.03x
💻 LocalExpress0.504s (-48.8% 🟢)1.005s (-6.6% 🟢)0.500s601.15x
💻 LocalNitro0.524s (-46.5% 🟢)1.022s (-6.6% 🟢)0.498s591.19x
🌐 RedisNext.js (Turbopack)0.617s1.004s0.388s601.40x
🐘 PostgresNext.js (Turbopack)0.665s1.006s0.341s601.51x
💻 LocalNext.js (Turbopack)0.726s1.004s0.278s601.65x
🌐 MongoDBNext.js (Turbopack)0.744s1.006s0.262s601.69x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.295s (-76.0% 🟢)7.121s (-70.4% 🟢)1.826s91.00x
▲ VercelNext.js (Turbopack)6.625s (-54.3% 🟢)8.457s (-47.4% 🟢)1.832s81.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.015s (-47.4% 🟢)1.532s (-27.1% 🟢)0.518s591.00x
🐘 PostgresExpress1.052s (-46.8% 🟢)1.632s (-27.7% 🟢)0.580s561.04x
💻 LocalNitro1.204s (-60.3% 🟢)2.006s (-46.6% 🟢)0.801s451.19x
💻 LocalExpress1.286s (-57.4% 🟢)2.006s (-44.0% 🟢)0.720s451.27x
🌐 RedisNext.js (Turbopack)1.476s2.006s0.529s451.46x
🐘 PostgresNext.js (Turbopack)1.585s2.007s0.423s451.56x
💻 LocalNext.js (Turbopack)1.764s2.006s0.241s451.74x
🌐 MongoDBNext.js (Turbopack)1.840s2.007s0.168s451.81x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro12.861s (-67.4% 🟢)14.586s (-64.7% 🟢)1.725s71.00x
▲ VercelNext.js (Turbopack)16.086s (-67.7% 🟢)18.350s (-64.5% 🟢)2.264s51.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 50 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro2.063s (-49.7% 🟢)2.549s (-44.6% 🟢)0.486s481.00x
🐘 PostgresExpress2.126s (-46.7% 🟢)2.719s (-37.8% 🟢)0.592s451.03x
💻 LocalNitro2.678s (-71.2% 🟢)3.008s (-70.0% 🟢)0.330s401.30x
💻 LocalExpress2.803s (-69.6% 🟢)3.033s (-69.7% 🟢)0.230s401.36x
🌐 RedisNext.js (Turbopack)2.963s3.135s0.173s391.44x
🐘 PostgresNext.js (Turbopack)3.131s4.008s0.877s301.52x
💻 LocalNext.js (Turbopack)3.767s4.007s0.240s301.83x
🌐 MongoDBNext.js (Turbopack)4.174s5.012s0.838s242.02x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro40.280s (-58.4% 🟢)42.530s (-56.8% 🟢)2.250s31.00x
▲ VercelNext.js (Turbopack)46.873s (-56.3% 🟢)48.931s (-55.1% 🟢)2.058s31.16x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 10 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.187s (-33.9% 🟢)1.006s (~)0.818s601.00x
🐘 PostgresExpress0.190s (-32.8% 🟢)1.006s (~)0.816s601.01x
🐘 PostgresNext.js (Turbopack)0.236s1.006s0.770s601.26x
🌐 RedisNext.js (Turbopack)0.242s1.004s0.762s601.30x
💻 LocalNitro0.469s (-22.5% 🟢)1.021s (~)0.553s592.50x
💻 LocalExpress0.483s (-13.8% 🟢)1.005s (~)0.522s602.58x
💻 LocalNext.js (Turbopack)0.554s1.005s0.451s602.96x
🌐 MongoDBNext.js (Turbopack)1.030s1.825s0.794s335.50x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.619s (+57.7% 🔺)4.178s (+24.7% 🔺)1.559s151.00x
▲ VercelNext.js (Turbopack)3.871s (+91.4% 🔺)5.504s (+45.1% 🔺)1.633s121.48x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.315s (-36.6% 🟢)1.006s (~)0.691s901.00x
🐘 PostgresExpress0.325s (-36.3% 🟢)1.007s (~)0.682s901.03x
🌐 RedisNext.js (Turbopack)0.410s1.004s0.594s901.30x
🐘 PostgresNext.js (Turbopack)0.458s1.006s0.548s901.45x
💻 LocalNitro2.270s (-10.6% 🟢)2.944s (-2.2%)0.675s317.21x
💻 LocalExpress2.282s (-9.2% 🟢)3.009s (~)0.727s307.25x
💻 LocalNext.js (Turbopack)2.466s3.042s0.576s307.84x
🌐 MongoDBNext.js (Turbopack)2.605s3.007s0.402s308.28x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)8.211s (+132.3% 🔺)9.775s (+88.2% 🔺)1.564s101.00x
▲ VercelNitro9.758s (+202.5% 🔺)11.351s (+135.4% 🔺)1.593s81.19x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

workflow with 50 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.652s (-17.5% 🟢)1.006s (~)0.354s1201.00x
🐘 PostgresExpress0.697s (-14.9% 🟢)1.007s (-1.0%)0.310s1201.07x
🌐 RedisNext.js (Turbopack)0.755s1.004s0.249s1201.16x
🐘 PostgresNext.js (Turbopack)0.944s1.340s0.397s901.45x
🌐 MongoDBNext.js (Turbopack)5.389s6.013s0.624s208.27x
💻 LocalNitro10.289s (-8.1% 🟢)10.781s (-7.6% 🟢)0.492s1215.78x
💻 LocalExpress11.054s (-1.2%)11.668s (-2.3%)0.615s1116.96x
💻 LocalNext.js (Turbopack)11.576s12.233s0.657s1017.76x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)19.155s (+85.5% 🔺)21.092s (+71.7% 🔺)1.938s61.00x
▲ VercelNitro23.620s (+205.8% 🔺)25.372s (+169.9% 🔺)1.753s51.23x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.133s (+452.2% 🔺)1.997s (+100.0% 🔺)0.001s (-18.8% 🟢)2.011s (+98.8% 🔺)0.878s101.00x
🐘 PostgresNitro1.140s (+456.1% 🔺)1.997s (+99.8% 🔺)0.001s (-13.3% 🟢)2.011s (+98.8% 🔺)0.871s101.01x
💻 LocalNitro1.141s (+434.1% 🔺)2.005s (+99.6% 🔺)0.013s (+1.6%)2.021s (+98.3% 🔺)0.879s101.01x
💻 LocalExpress1.142s (+473.8% 🔺)2.006s (+99.7% 🔺)0.013s (+4.1%)2.021s (+98.5% 🔺)0.878s101.01x
💻 LocalNext.js (Turbopack)1.176s2.004s0.012s2.020s0.844s101.04x
🐘 PostgresNext.js (Turbopack)1.196s2.001s0.002s2.011s0.816s101.06x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.149s (-43.9% 🟢)3.058s (-42.1% 🟢)1.931s (+160.2% 🔺)5.669s (-12.6% 🟢)3.520s101.00x
▲ VercelNext.js (Turbopack)4.815s (-29.7% 🟢)5.037s (-41.8% 🟢)0.879s (+39.1% 🔺)7.516s (-23.2% 🟢)2.701s102.24x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

stream pipeline with 5 transform steps (1MB)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.522s (+143.9% 🔺)1.999s (+98.6% 🔺)0.004s (-9.7% 🟢)2.025s (+98.1% 🔺)0.503s301.00x
🐘 PostgresExpress1.563s (+148.0% 🔺)2.005s (+99.2% 🔺)0.004s (-4.3%)2.025s (+98.0% 🔺)0.463s301.03x
💻 LocalNext.js (Turbopack)1.664s2.010s0.009s2.023s0.359s301.09x
🐘 PostgresNext.js (Turbopack)1.669s2.009s0.004s2.024s0.355s301.10x
💻 LocalNitro1.705s (+103.2% 🔺)2.011s (+98.7% 🔺)0.009s (-7.0% 🟢)2.201s (+97.2% 🔺)0.496s281.12x
💻 LocalExpress1.755s (+131.8% 🔺)2.012s (+95.6% 🔺)0.011s (+14.6% 🔺)2.204s (+112.0% 🔺)0.449s281.15x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.949s (-79.8% 🟢)7.135s (-76.8% 🟢)0.212s (+89.2% 🔺)7.803s (-75.4% 🟢)1.855s81.00x
▲ VercelNext.js (Turbopack)12.421s (-26.6% 🟢)12.915s (-29.2% 🟢)0.180s (-14.7% 🟢)14.203s (-25.0% 🟢)1.782s52.09x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

10 parallel streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.674s (-30.4% 🟢)1.050s (-15.9% 🟢)0.000s (-15.8% 🟢)1.064s (-15.4% 🟢)0.390s571.00x
🐘 PostgresExpress0.714s (-25.7% 🟢)1.031s (-19.3% 🟢)0.000s (-100.0% 🟢)1.043s (-20.1% 🟢)0.329s581.06x
🐘 PostgresNext.js (Turbopack)0.787s1.035s0.000s1.049s0.262s581.17x
💻 LocalNitro1.303s (+6.6% 🔺)2.015s (~)0.000s (+166.7% 🔺)2.017s (~)0.714s301.93x
💻 LocalExpress1.426s (+16.4% 🔺)2.015s (~)0.000s (-20.0% 🟢)2.018s (~)0.591s302.11x
💻 LocalNext.js (Turbopack)1.611s2.014s0.000s2.197s0.586s282.39x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.728s (+22.2% 🔺)4.649s (+5.8% 🔺)0.001s (+766.7% 🔺)5.068s (+5.4% 🔺)1.340s121.00x
▲ VercelNext.js (Turbopack)7.287s (-28.4% 🟢)7.260s (-37.0% 🟢)0.000s (NaN%)9.165s (-23.9% 🟢)1.878s71.95x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

fan-out fan-in 10 streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.383s (-22.8% 🟢)2.141s (~)0.000s (+100.0% 🔺)2.153s (-1.0%)0.770s281.00x
🐘 PostgresExpress1.504s (-15.1% 🟢)2.097s (-3.7%)0.000s (NaN%)2.131s (-3.1%)0.627s291.09x
🐘 PostgresNext.js (Turbopack)1.667s2.224s0.000s2.233s0.566s271.21x
💻 LocalNext.js (Turbopack)2.804s3.361s0.000s3.365s0.561s182.03x
💻 LocalNitro3.108s (-8.2% 🟢)3.841s (-4.7%)0.000s (-18.0% 🟢)3.843s (-4.8%)0.735s162.25x
💻 LocalExpress3.249s (-6.3% 🟢)3.842s (-4.7%)0.001s (-21.9% 🟢)3.845s (-4.7%)0.596s162.35x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.969s (+45.8% 🔺)7.219s (+34.3% 🔺)0.000s (-100.0% 🟢)7.627s (+31.6% 🔺)1.658s81.00x
▲ VercelNext.js (Turbopack)9.307s (+65.7% 🔺)9.811s (+40.5% 🔺)0.001s (+300.0% 🔺)11.072s (+46.8% 🔺)1.765s61.56x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro15/21
🐘 PostgresNitro12/21
▲ VercelNitro18/21
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express🐘 Postgres19/21
Next.js (Turbopack)🐘 Postgres10/21
Nitro🐘 Postgres17/21
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)
  • Slurp: Time from first byte to complete stream consumption (stream benchmarks only)
  • Wall Time: Total testbench time (trigger workflow + poll for result)
  • Overhead: Testbench overhead (Wall Time - Workflow Time)
  • Samples: Number of benchmark iterations run
  • vs Fastest: How much slower compared to the fastest configuration for this benchmark

Worlds:

  • 💻 Local: In-memory filesystem world (local development)
  • 🐘 Postgres: PostgreSQL database world (local development)
  • ▲ Vercel: Vercel production/preview deployment
  • 🌐 Turso: Community world (local development)
  • 🌐 MongoDB: Community world (local development)
  • 🌐 Redis: Community world (local development)
  • 🌐 Jazz: Community world (local development)

📋 View full workflow run


Some benchmark jobs failed:

  • Local: success
  • Postgres: success
  • Vercel: failure

Check the workflow run for details.

@karthikscale3karthikscale3 left a comment

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.

LGTM. Verified it in the SWC playground.

CopilotAI left a comment

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.

Pull request overview

This PR adjusts the SWC workflow transform so dead-code elimination runs after nested step hoisting, with the goal of preserving module imports that hoisted step bodies still reference in step-mode output.

Changes:

  • Moves remove_dead_code from visit_mut_module_items to the end of visit_mut_program.
  • Updates existing step-mode fixtures whose hoisted steps now correctly retain required imports.
  • Adds a regression fixture covering nested steps that reference module-level imports.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
packages/swc-plugin-workflow/transform/tests/fixture/nested-steps-in-object-constructor/output-step.jsUpdates expected step output to retain an import used by a hoisted nested step.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-with-closure/output-step.jsUpdates expected step output to retain an import referenced from hoisted closure-based steps.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/output-workflow.jsAdds workflow-mode regression output for the new nested-import fixture.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/output-step.jsAdds step-mode regression output showing preserved imports for a hoisted nested step.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/input.jsAdds the new regression input covering nested step references to module imports.
packages/swc-plugin-workflow/transform/tests/fixture/factory-with-step-method/output-step.jsUpdates expected step output to retain an import used by a hoisted step method.
packages/swc-plugin-workflow/transform/src/lib.rsDefers dead-code elimination until after nested step hoisting completes.
.changeset/preserve-imports-used-by-hoisted-steps.mdRecords the patch release note for the SWC plugin fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/swc-plugin-workflow/transform/src/lib.rs
…nctions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.

CopilotAI left a comment

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.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/swc-plugin-workflow/transform/src/lib.rs
Comment thread.changeset/preserve-imports-used-by-hoisted-steps.md Outdated
…n shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
@TooTallNate
TooTallNate enabled auto-merge (squash) May 5, 2026 21:34
@TooTallNate
TooTallNate merged commit 1d4f83a into mainMay 5, 2026
113 of 114 checks passed
@TooTallNate
TooTallNate deleted the swc-plugin/preserve-imports-for-hoisted-steps branch May 5, 2026 21:36
github-actionsBot added a commit that referenced this pull request May 5, 2026
* [swc-plugin] Preserve imports referenced by hoisted nested steps
Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
* [swc-plugin] Namespace nested step IDs under non-exported workflow functions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.
* [swc-plugin] Namespace nested step IDs across all workflow declaration shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
Signed-off-by: Nathan Rajlich <n@n8.io>
@github-actions

Copy link
Copy Markdown
Contributor

Backport PR opened against stable: #1946. Merge conflicts were resolved by AI — please review carefully.

TooTallNate added a commit that referenced this pull request May 22, 2026
…) (#1946)
* [swc-plugin] Preserve imports referenced by hoisted nested steps
Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
* [swc-plugin] Namespace nested step IDs under non-exported workflow functions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.
* [swc-plugin] Namespace nested step IDs across all workflow declaration shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
Signed-off-by: Nathan Rajlich <n@n8.io>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Nathan Rajlich <n@n8.io>
@github-actionsgithub-actionsBot mentioned this pull request May 22, 2026
TooTallNate added a commit that referenced this pull request May 22, 2026
The fixture was introduced by the backport of #1935 (#1945) with the
pre-namespacing step ID "step//./input//step" in the __internal_workflows
manifest comment. The subsequent backport of #1944 (#1946) shipped the
namespacing fix in lib.rs but did not update this fixture, since on main
the two PRs landed in the reverse order and #1944's diff already covered
the fixture there.
Update the expected output to match what the plugin now emits:
"step//./input//outer/step" — same value already present in main.
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.

3 participants

@TooTallNate@karthikscale3
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

[swc-plugin] Preserve imports referenced by hoisted nested steps - #1944

Merged
TooTallNate merged 3 commits into
mainfrom
swc-plugin/preserve-imports-for-hoisted-steps
May 5, 2026
Merged

[swc-plugin] Preserve imports referenced by hoisted nested steps#1944
TooTallNate merged 3 commits into
mainfrom
swc-plugin/preserve-imports-for-hoisted-steps

Conversation

@TooTallNate

Copy link
Copy Markdown
Member

Summary

Fixes a bug in the SWC plugin where step-mode bundles dropped module-level imports that were referenced by step functions hoisted out of workflow bodies, causing a ReferenceError at runtime.

Root Cause

Ordering bug in the transform pipeline:

  1. StepTransform::visit_mut_module_items runs and, at the end, invokes remove_dead_code, which strips any import not referenced by current top-level code.
  2. StepTransform::visit_mut_program then hoists nested step functions out of workflow bodies onto the module top level (e.g. var _anonymousStep0 = async (input) => db.query(input.query);).
  3. The hoisted body references db, but the import was already deleted in step 1.

This only affected steps nested inside workflow function bodies — top-level steps already worked because their bodies were inlined in items before DCE ran. Three pre-existing fixtures (nested-step-with-closure, nested-steps-in-object-constructor, factory-with-step-method) had committed buggy outputs that this change corrects.

For example, given:

import{db}from'./db';asyncfunctionw(){'use workflow';constagent=newWorkflowAgent({tools: ()=>({queryDatabase: tool({execute: async(input)=>{'use step';returndb.query(input.query);},}),}),});}

The previous step-mode output omitted import { db } from './db'; while still emitting var _anonymousStep0 = async (input) => db.query(input.query);.

Fix

In packages/swc-plugin-workflow/transform/src/lib.rs:

  • Removed the early remove_dead_code call from the end of visit_mut_module_items.
  • Added a single remove_dead_code(&mut module.body) call in visit_mut_program, after nested step hoisting completes (right before metadata-comment insertion).

Verification

  • Added regression fixture tests/fixture/nested-step-references-module-import/ covering both kept-imports (used by hoisted step) and stripped-imports (truly unused, or only used by replaced workflow body).
  • All 124 SWC fixture tests pass.
  • Three pre-existing fixtures had their output-step.js files updated to now correctly include the imports their hoisted steps reference.
  • spec.md already documented the desired behavior — no spec change needed; this is purely an implementation conformance fix.

Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
CopilotAI review requested due to automatic review settings May 5, 2026 20:21
@vercel

vercelBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

@changeset-bot

changeset-botBot commented May 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9d132e5

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

This PR includes changesets to release 19 packages
NameType
@workflow/swc-pluginPatch
@workflow/astroPatch
@workflow/buildersPatch
@workflow/cliPatch
@workflow/nestPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
tarballsPatch
workflowPatch
@workflow/vitePatch
@workflow/vitestPatch
@workflow/world-testingPatch
@workflow/nuxtPatch
@workflow/aiPatch
@workflow/corePatch
@workflow/web-sharedPatch
@workflow/webPatch

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

@github-actions

github-actionsBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production120002191419
✅ 💻 Local Development158702191806
✅ 📦 Local Production158702191806
✅ 🐘 Local Postgres158702191806
✅ 🪟 Windows12900129
✅ 📋 Other7270176903
Total6817010527869

Details by Category

✅ ▲ Vercel Production
AppPassedFailedSkipped
✅ astro103026
✅ example103026
✅ express103026
✅ fastify103026
✅ hono103026
✅ nextjs-turbopack12702
✅ nextjs-webpack12702
✅ nitro103026
✅ nuxt103026
✅ sveltekit12207
✅ vite103026
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack12900
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable104025
✅ e2e-local-dev-tanstack-start-104025
✅ e2e-local-postgres-nest-stable104025
✅ e2e-local-postgres-tanstack-start-104025
✅ e2e-local-prod-nest-stable104025
✅ e2e-local-prod-tanstack-start-104025
✅ e2e-vercel-prod-tanstack-start103026

📋 View full workflow run

@github-actions

github-actionsBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

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

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.033s (-22.7% 🟢)1.005s (~)0.972s101.00x
💻 LocalExpress0.036s (-19.2% 🟢)1.006s (~)0.970s101.08x
🐘 PostgresExpress0.045s (-21.7% 🟢)1.011s (~)0.965s101.36x
💻 LocalNext.js (Turbopack)0.049s1.005s0.956s101.47x
🐘 PostgresNitro0.051s (-47.0% 🟢)1.011s (-3.1%)0.961s101.52x
🌐 RedisNext.js (Turbopack)0.052s1.005s0.953s101.56x
🐘 PostgresNext.js (Turbopack)0.057s1.011s0.954s101.71x
🌐 MongoDBNext.js (Turbopack)0.129s1.007s0.879s103.86x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro0.220s (-46.4% 🟢)2.151s (-14.3% 🟢)1.931s101.00x
▲ VercelNext.js (Turbopack)1.154s (+359.0% 🔺)2.852s (+22.3% 🔺)1.698s105.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Express1.075s (-4.5%)2.007s (~)0.931s101.00x
💻 LocalNitro1.075s (-5.0%)2.006s (~)0.931s101.00x
🐘 PostgresNitro1.083s (-5.0%)2.009s (~)0.926s101.01x
🐘 PostgresExpress1.084s (-5.4% 🟢)2.009s (~)0.925s101.01x
💻 LocalNext.js (Turbopack)1.110s2.006s0.896s101.03x
🌐 RedisNext.js (Turbopack)1.111s2.006s0.895s101.03x
🐘 PostgresNext.js (Turbopack)1.129s2.008s0.879s101.05x
🌐 MongoDBNext.js (Turbopack)1.169s2.009s0.840s101.09x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro1.608s (-58.7% 🟢)3.463s (-41.4% 🟢)1.855s101.00x
▲ VercelNext.js (Turbopack)3.023s (+48.6% 🔺)4.583s (+19.6% 🔺)1.560s101.88x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro10.404s (-4.9%)11.023s (~)0.618s31.00x
🐘 PostgresExpress10.408s (-5.1% 🟢)11.018s (~)0.611s31.00x
🐘 PostgresNitro10.419s (-4.2%)11.016s (~)0.597s31.00x
💻 LocalExpress10.424s (-4.6%)11.022s (~)0.598s31.00x
🐘 PostgresNext.js (Turbopack)10.657s11.016s0.359s31.02x
💻 LocalNext.js (Turbopack)10.669s11.021s0.353s31.03x
🌐 RedisNext.js (Turbopack)10.691s11.022s0.332s31.03x
🌐 MongoDBNext.js (Turbopack)10.894s11.352s0.458s31.05x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro13.342s (-43.8% 🟢)14.917s (-40.6% 🟢)1.575s31.00x
▲ VercelNext.js (Turbopack)13.784s (-20.4% 🟢)15.604s (-19.6% 🟢)1.821s21.03x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express13.447s (-7.8% 🟢)14.017s (-6.7% 🟢)0.570s51.00x
🐘 PostgresNitro13.451s (-7.8% 🟢)14.015s (-6.7% 🟢)0.565s51.00x
💻 LocalNitro13.507s (-10.3% 🟢)14.027s (-12.5% 🟢)0.520s51.00x
💻 LocalExpress13.523s (-9.7% 🟢)14.028s (-6.7% 🟢)0.505s51.01x
💻 LocalNext.js (Turbopack)14.061s14.828s0.767s51.05x
🌐 RedisNext.js (Turbopack)14.100s15.029s0.929s41.05x
🐘 PostgresNext.js (Turbopack)14.112s15.017s0.905s41.05x
🌐 MongoDBNext.js (Turbopack)14.354s15.026s0.672s41.07x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro21.643s (-66.4% 🟢)23.304s (-65.0% 🟢)1.660s31.00x
▲ VercelNext.js (Turbopack)23.990s (-54.4% 🟢)25.981s (-52.4% 🟢)1.991s31.11x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express11.854s (-15.4% 🟢)12.015s (-17.7% 🟢)0.161s81.00x
💻 LocalNitro11.930s (-28.9% 🟢)12.022s (-29.4% 🟢)0.092s81.01x
🐘 PostgresNitro11.936s (-14.5% 🟢)12.266s (-14.3% 🟢)0.330s81.01x
💻 LocalExpress12.068s (-27.3% 🟢)12.774s (-25.0% 🟢)0.706s81.02x
🌐 RedisNext.js (Turbopack)12.966s13.310s0.344s71.09x
💻 LocalNext.js (Turbopack)13.010s13.167s0.157s71.10x
🐘 PostgresNext.js (Turbopack)13.305s14.016s0.710s71.12x
🌐 MongoDBNext.js (Turbopack)13.338s14.023s0.684s71.13x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro32.625s (-92.3% 🟢)34.494s (-91.9% 🟢)1.869s31.00x
▲ VercelNext.js (Turbopack)35.758s (-90.9% 🟢)37.455s (-90.5% 🟢)1.697s31.10x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.146s (-10.1% 🟢)2.007s (~)0.861s151.00x
🐘 PostgresExpress1.149s (-8.8% 🟢)2.007s (~)0.857s151.00x
💻 LocalNitro1.186s (-27.3% 🟢)2.006s (-3.3%)0.820s151.04x
💻 LocalExpress1.195s (-19.7% 🟢)2.006s (~)0.811s151.04x
🐘 PostgresNext.js (Turbopack)1.235s2.007s0.772s151.08x
🌐 RedisNext.js (Turbopack)1.254s2.006s0.752s151.09x
💻 LocalNext.js (Turbopack)1.292s2.006s0.714s151.13x
🌐 MongoDBNext.js (Turbopack)2.028s2.735s0.707s111.77x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.906s (+3.1%)4.524s (+4.7%)1.618s71.00x
▲ VercelNext.js (Turbopack)4.911s (+44.6% 🔺)6.214s (+26.0% 🔺)1.303s51.69x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.219s (-48.4% 🟢)2.008s (-33.3% 🟢)0.789s151.00x
🐘 PostgresNitro1.230s (-47.7% 🟢)2.007s (-33.3% 🟢)0.777s151.01x
🐘 PostgresNext.js (Turbopack)1.355s2.007s0.652s151.11x
💻 LocalNitro1.777s (-43.5% 🟢)2.006s (-48.4% 🟢)0.228s151.46x
💻 LocalNext.js (Turbopack)1.824s2.006s0.183s151.50x
💻 LocalExpress1.879s (-36.4% 🟢)2.223s (-35.6% 🟢)0.344s141.54x
🌐 RedisNext.js (Turbopack)2.358s3.008s0.650s101.93x
🌐 MongoDBNext.js (Turbopack)3.576s4.009s0.433s82.93x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.582s (-11.6% 🟢)5.158s (-12.9% 🟢)1.577s71.00x
▲ VercelNext.js (Turbopack)5.608s (-21.0% 🟢)7.256s (-18.5% 🟢)1.648s51.57x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.367s (-60.8% 🟢)2.007s (-49.9% 🟢)0.640s151.00x
🐘 PostgresNitro1.376s (-60.5% 🟢)2.007s (-49.9% 🟢)0.632s151.01x
🐘 PostgresNext.js (Turbopack)1.639s2.074s0.435s151.20x
🌐 RedisNext.js (Turbopack)3.586s4.010s0.423s82.62x
💻 LocalNitro5.274s (-36.8% 🟢)5.846s (-35.2% 🟢)0.572s63.86x
💻 LocalExpress5.587s (-33.0% 🟢)6.213s (-31.2% 🟢)0.626s54.09x
💻 LocalNext.js (Turbopack)5.748s6.213s0.465s54.20x
🌐 MongoDBNext.js (Turbopack)6.301s7.013s0.712s54.61x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.978s (+69.6% 🔺)8.125s (+46.8% 🔺)2.147s41.00x
▲ VercelNext.js (Turbopack)7.377s (-17.3% 🟢)9.561s (-12.8% 🟢)2.184s41.23x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.150s (-8.5% 🟢)2.008s (~)0.858s151.00x
🐘 PostgresNitro1.169s (-7.0% 🟢)2.008s (~)0.839s151.02x
🐘 PostgresNext.js (Turbopack)1.218s2.008s0.790s151.06x
🌐 RedisNext.js (Turbopack)1.240s2.006s0.766s151.08x
💻 LocalNext.js (Turbopack)1.322s2.006s0.684s151.15x
💻 LocalNitro1.398s (-25.1% 🟢)2.006s (-14.3% 🟢)0.608s151.22x
💻 LocalExpress1.423s (-24.8% 🟢)2.006s (-15.1% 🟢)0.583s151.24x
🌐 MongoDBNext.js (Turbopack)2.029s2.675s0.645s121.76x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.689s (+9.3% 🔺)4.494s (+7.8% 🔺)1.805s71.00x
▲ VercelNext.js (Turbopack)3.798s (+29.5% 🔺)5.672s (+22.2% 🔺)1.874s61.41x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.229s (-47.5% 🟢)2.008s (-33.3% 🟢)0.779s151.00x
🐘 PostgresNitro1.247s (-46.7% 🟢)2.008s (-33.3% 🟢)0.760s151.02x
🐘 PostgresNext.js (Turbopack)1.386s2.008s0.622s151.13x
💻 LocalExpress2.079s (-33.6% 🟢)2.510s (-33.3% 🟢)0.430s121.69x
💻 LocalNext.js (Turbopack)2.117s2.735s0.617s111.72x
💻 LocalNitro2.169s (-29.2% 🟢)2.593s (-33.3% 🟢)0.424s121.77x
🌐 RedisNext.js (Turbopack)2.343s3.008s0.665s101.91x
🌐 MongoDBNext.js (Turbopack)3.579s4.009s0.430s82.91x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.315s (+2.5%)4.910s (-3.3%)1.595s71.00x
▲ VercelNext.js (Turbopack)5.136s (+63.4% 🔺)7.036s (+55.6% 🔺)1.901s51.55x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.377s (-60.4% 🟢)2.007s (-49.9% 🟢)0.630s151.00x
🐘 PostgresExpress1.386s (-60.4% 🟢)2.008s (-49.9% 🟢)0.622s151.01x
🐘 PostgresNext.js (Turbopack)1.637s2.007s0.370s151.19x
🌐 RedisNext.js (Turbopack)3.635s4.009s0.374s82.64x
💻 LocalNitro5.492s (-39.9% 🟢)6.214s (-38.0% 🟢)0.722s53.99x
💻 LocalNext.js (Turbopack)5.810s6.413s0.603s54.22x
💻 LocalExpress5.859s (-33.4% 🟢)6.616s (-28.7% 🟢)0.757s54.25x
🌐 MongoDBNext.js (Turbopack)6.297s7.013s0.716s54.57x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)6.088s (-9.9% 🟢)8.239s (-3.6%)2.151s41.00x
▲ VercelNitro6.546s (+28.5% 🔺)8.394s (+23.1% 🔺)1.849s41.08x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

workflow with 10 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.440s (-46.4% 🟢)1.006s (~)0.566s601.00x
🐘 PostgresExpress0.454s (-45.8% 🟢)1.006s (-1.7%)0.552s601.03x
💻 LocalExpress0.504s (-48.8% 🟢)1.005s (-6.6% 🟢)0.500s601.15x
💻 LocalNitro0.524s (-46.5% 🟢)1.022s (-6.6% 🟢)0.498s591.19x
🌐 RedisNext.js (Turbopack)0.617s1.004s0.388s601.40x
🐘 PostgresNext.js (Turbopack)0.665s1.006s0.341s601.51x
💻 LocalNext.js (Turbopack)0.726s1.004s0.278s601.65x
🌐 MongoDBNext.js (Turbopack)0.744s1.006s0.262s601.69x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.295s (-76.0% 🟢)7.121s (-70.4% 🟢)1.826s91.00x
▲ VercelNext.js (Turbopack)6.625s (-54.3% 🟢)8.457s (-47.4% 🟢)1.832s81.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.015s (-47.4% 🟢)1.532s (-27.1% 🟢)0.518s591.00x
🐘 PostgresExpress1.052s (-46.8% 🟢)1.632s (-27.7% 🟢)0.580s561.04x
💻 LocalNitro1.204s (-60.3% 🟢)2.006s (-46.6% 🟢)0.801s451.19x
💻 LocalExpress1.286s (-57.4% 🟢)2.006s (-44.0% 🟢)0.720s451.27x
🌐 RedisNext.js (Turbopack)1.476s2.006s0.529s451.46x
🐘 PostgresNext.js (Turbopack)1.585s2.007s0.423s451.56x
💻 LocalNext.js (Turbopack)1.764s2.006s0.241s451.74x
🌐 MongoDBNext.js (Turbopack)1.840s2.007s0.168s451.81x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro12.861s (-67.4% 🟢)14.586s (-64.7% 🟢)1.725s71.00x
▲ VercelNext.js (Turbopack)16.086s (-67.7% 🟢)18.350s (-64.5% 🟢)2.264s51.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 50 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro2.063s (-49.7% 🟢)2.549s (-44.6% 🟢)0.486s481.00x
🐘 PostgresExpress2.126s (-46.7% 🟢)2.719s (-37.8% 🟢)0.592s451.03x
💻 LocalNitro2.678s (-71.2% 🟢)3.008s (-70.0% 🟢)0.330s401.30x
💻 LocalExpress2.803s (-69.6% 🟢)3.033s (-69.7% 🟢)0.230s401.36x
🌐 RedisNext.js (Turbopack)2.963s3.135s0.173s391.44x
🐘 PostgresNext.js (Turbopack)3.131s4.008s0.877s301.52x
💻 LocalNext.js (Turbopack)3.767s4.007s0.240s301.83x
🌐 MongoDBNext.js (Turbopack)4.174s5.012s0.838s242.02x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro40.280s (-58.4% 🟢)42.530s (-56.8% 🟢)2.250s31.00x
▲ VercelNext.js (Turbopack)46.873s (-56.3% 🟢)48.931s (-55.1% 🟢)2.058s31.16x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 10 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.187s (-33.9% 🟢)1.006s (~)0.818s601.00x
🐘 PostgresExpress0.190s (-32.8% 🟢)1.006s (~)0.816s601.01x
🐘 PostgresNext.js (Turbopack)0.236s1.006s0.770s601.26x
🌐 RedisNext.js (Turbopack)0.242s1.004s0.762s601.30x
💻 LocalNitro0.469s (-22.5% 🟢)1.021s (~)0.553s592.50x
💻 LocalExpress0.483s (-13.8% 🟢)1.005s (~)0.522s602.58x
💻 LocalNext.js (Turbopack)0.554s1.005s0.451s602.96x
🌐 MongoDBNext.js (Turbopack)1.030s1.825s0.794s335.50x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.619s (+57.7% 🔺)4.178s (+24.7% 🔺)1.559s151.00x
▲ VercelNext.js (Turbopack)3.871s (+91.4% 🔺)5.504s (+45.1% 🔺)1.633s121.48x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.315s (-36.6% 🟢)1.006s (~)0.691s901.00x
🐘 PostgresExpress0.325s (-36.3% 🟢)1.007s (~)0.682s901.03x
🌐 RedisNext.js (Turbopack)0.410s1.004s0.594s901.30x
🐘 PostgresNext.js (Turbopack)0.458s1.006s0.548s901.45x
💻 LocalNitro2.270s (-10.6% 🟢)2.944s (-2.2%)0.675s317.21x
💻 LocalExpress2.282s (-9.2% 🟢)3.009s (~)0.727s307.25x
💻 LocalNext.js (Turbopack)2.466s3.042s0.576s307.84x
🌐 MongoDBNext.js (Turbopack)2.605s3.007s0.402s308.28x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)8.211s (+132.3% 🔺)9.775s (+88.2% 🔺)1.564s101.00x
▲ VercelNitro9.758s (+202.5% 🔺)11.351s (+135.4% 🔺)1.593s81.19x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

workflow with 50 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.652s (-17.5% 🟢)1.006s (~)0.354s1201.00x
🐘 PostgresExpress0.697s (-14.9% 🟢)1.007s (-1.0%)0.310s1201.07x
🌐 RedisNext.js (Turbopack)0.755s1.004s0.249s1201.16x
🐘 PostgresNext.js (Turbopack)0.944s1.340s0.397s901.45x
🌐 MongoDBNext.js (Turbopack)5.389s6.013s0.624s208.27x
💻 LocalNitro10.289s (-8.1% 🟢)10.781s (-7.6% 🟢)0.492s1215.78x
💻 LocalExpress11.054s (-1.2%)11.668s (-2.3%)0.615s1116.96x
💻 LocalNext.js (Turbopack)11.576s12.233s0.657s1017.76x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)19.155s (+85.5% 🔺)21.092s (+71.7% 🔺)1.938s61.00x
▲ VercelNitro23.620s (+205.8% 🔺)25.372s (+169.9% 🔺)1.753s51.23x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.133s (+452.2% 🔺)1.997s (+100.0% 🔺)0.001s (-18.8% 🟢)2.011s (+98.8% 🔺)0.878s101.00x
🐘 PostgresNitro1.140s (+456.1% 🔺)1.997s (+99.8% 🔺)0.001s (-13.3% 🟢)2.011s (+98.8% 🔺)0.871s101.01x
💻 LocalNitro1.141s (+434.1% 🔺)2.005s (+99.6% 🔺)0.013s (+1.6%)2.021s (+98.3% 🔺)0.879s101.01x
💻 LocalExpress1.142s (+473.8% 🔺)2.006s (+99.7% 🔺)0.013s (+4.1%)2.021s (+98.5% 🔺)0.878s101.01x
💻 LocalNext.js (Turbopack)1.176s2.004s0.012s2.020s0.844s101.04x
🐘 PostgresNext.js (Turbopack)1.196s2.001s0.002s2.011s0.816s101.06x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.149s (-43.9% 🟢)3.058s (-42.1% 🟢)1.931s (+160.2% 🔺)5.669s (-12.6% 🟢)3.520s101.00x
▲ VercelNext.js (Turbopack)4.815s (-29.7% 🟢)5.037s (-41.8% 🟢)0.879s (+39.1% 🔺)7.516s (-23.2% 🟢)2.701s102.24x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

stream pipeline with 5 transform steps (1MB)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.522s (+143.9% 🔺)1.999s (+98.6% 🔺)0.004s (-9.7% 🟢)2.025s (+98.1% 🔺)0.503s301.00x
🐘 PostgresExpress1.563s (+148.0% 🔺)2.005s (+99.2% 🔺)0.004s (-4.3%)2.025s (+98.0% 🔺)0.463s301.03x
💻 LocalNext.js (Turbopack)1.664s2.010s0.009s2.023s0.359s301.09x
🐘 PostgresNext.js (Turbopack)1.669s2.009s0.004s2.024s0.355s301.10x
💻 LocalNitro1.705s (+103.2% 🔺)2.011s (+98.7% 🔺)0.009s (-7.0% 🟢)2.201s (+97.2% 🔺)0.496s281.12x
💻 LocalExpress1.755s (+131.8% 🔺)2.012s (+95.6% 🔺)0.011s (+14.6% 🔺)2.204s (+112.0% 🔺)0.449s281.15x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.949s (-79.8% 🟢)7.135s (-76.8% 🟢)0.212s (+89.2% 🔺)7.803s (-75.4% 🟢)1.855s81.00x
▲ VercelNext.js (Turbopack)12.421s (-26.6% 🟢)12.915s (-29.2% 🟢)0.180s (-14.7% 🟢)14.203s (-25.0% 🟢)1.782s52.09x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

10 parallel streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.674s (-30.4% 🟢)1.050s (-15.9% 🟢)0.000s (-15.8% 🟢)1.064s (-15.4% 🟢)0.390s571.00x
🐘 PostgresExpress0.714s (-25.7% 🟢)1.031s (-19.3% 🟢)0.000s (-100.0% 🟢)1.043s (-20.1% 🟢)0.329s581.06x
🐘 PostgresNext.js (Turbopack)0.787s1.035s0.000s1.049s0.262s581.17x
💻 LocalNitro1.303s (+6.6% 🔺)2.015s (~)0.000s (+166.7% 🔺)2.017s (~)0.714s301.93x
💻 LocalExpress1.426s (+16.4% 🔺)2.015s (~)0.000s (-20.0% 🟢)2.018s (~)0.591s302.11x
💻 LocalNext.js (Turbopack)1.611s2.014s0.000s2.197s0.586s282.39x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.728s (+22.2% 🔺)4.649s (+5.8% 🔺)0.001s (+766.7% 🔺)5.068s (+5.4% 🔺)1.340s121.00x
▲ VercelNext.js (Turbopack)7.287s (-28.4% 🟢)7.260s (-37.0% 🟢)0.000s (NaN%)9.165s (-23.9% 🟢)1.878s71.95x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

fan-out fan-in 10 streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.383s (-22.8% 🟢)2.141s (~)0.000s (+100.0% 🔺)2.153s (-1.0%)0.770s281.00x
🐘 PostgresExpress1.504s (-15.1% 🟢)2.097s (-3.7%)0.000s (NaN%)2.131s (-3.1%)0.627s291.09x
🐘 PostgresNext.js (Turbopack)1.667s2.224s0.000s2.233s0.566s271.21x
💻 LocalNext.js (Turbopack)2.804s3.361s0.000s3.365s0.561s182.03x
💻 LocalNitro3.108s (-8.2% 🟢)3.841s (-4.7%)0.000s (-18.0% 🟢)3.843s (-4.8%)0.735s162.25x
💻 LocalExpress3.249s (-6.3% 🟢)3.842s (-4.7%)0.001s (-21.9% 🟢)3.845s (-4.7%)0.596s162.35x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.969s (+45.8% 🔺)7.219s (+34.3% 🔺)0.000s (-100.0% 🟢)7.627s (+31.6% 🔺)1.658s81.00x
▲ VercelNext.js (Turbopack)9.307s (+65.7% 🔺)9.811s (+40.5% 🔺)0.001s (+300.0% 🔺)11.072s (+46.8% 🔺)1.765s61.56x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro15/21
🐘 PostgresNitro12/21
▲ VercelNitro18/21
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express🐘 Postgres19/21
Next.js (Turbopack)🐘 Postgres10/21
Nitro🐘 Postgres17/21
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)
  • Slurp: Time from first byte to complete stream consumption (stream benchmarks only)
  • Wall Time: Total testbench time (trigger workflow + poll for result)
  • Overhead: Testbench overhead (Wall Time - Workflow Time)
  • Samples: Number of benchmark iterations run
  • vs Fastest: How much slower compared to the fastest configuration for this benchmark

Worlds:

  • 💻 Local: In-memory filesystem world (local development)
  • 🐘 Postgres: PostgreSQL database world (local development)
  • ▲ Vercel: Vercel production/preview deployment
  • 🌐 Turso: Community world (local development)
  • 🌐 MongoDB: Community world (local development)
  • 🌐 Redis: Community world (local development)
  • 🌐 Jazz: Community world (local development)

📋 View full workflow run


Some benchmark jobs failed:

  • Local: success
  • Postgres: success
  • Vercel: failure

Check the workflow run for details.

@karthikscale3karthikscale3 left a comment

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.

LGTM. Verified it in the SWC playground.

CopilotAI left a comment

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.

Pull request overview

This PR adjusts the SWC workflow transform so dead-code elimination runs after nested step hoisting, with the goal of preserving module imports that hoisted step bodies still reference in step-mode output.

Changes:

  • Moves remove_dead_code from visit_mut_module_items to the end of visit_mut_program.
  • Updates existing step-mode fixtures whose hoisted steps now correctly retain required imports.
  • Adds a regression fixture covering nested steps that reference module-level imports.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
packages/swc-plugin-workflow/transform/tests/fixture/nested-steps-in-object-constructor/output-step.jsUpdates expected step output to retain an import used by a hoisted nested step.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-with-closure/output-step.jsUpdates expected step output to retain an import referenced from hoisted closure-based steps.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/output-workflow.jsAdds workflow-mode regression output for the new nested-import fixture.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/output-step.jsAdds step-mode regression output showing preserved imports for a hoisted nested step.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/input.jsAdds the new regression input covering nested step references to module imports.
packages/swc-plugin-workflow/transform/tests/fixture/factory-with-step-method/output-step.jsUpdates expected step output to retain an import used by a hoisted step method.
packages/swc-plugin-workflow/transform/src/lib.rsDefers dead-code elimination until after nested step hoisting completes.
.changeset/preserve-imports-used-by-hoisted-steps.mdRecords the patch release note for the SWC plugin fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/swc-plugin-workflow/transform/src/lib.rs
…nctions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.

CopilotAI left a comment

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.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/swc-plugin-workflow/transform/src/lib.rs
Comment thread.changeset/preserve-imports-used-by-hoisted-steps.md Outdated
…n shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
@TooTallNate
TooTallNate enabled auto-merge (squash) May 5, 2026 21:34
@TooTallNate
TooTallNate merged commit 1d4f83a into mainMay 5, 2026
113 of 114 checks passed
@TooTallNate
TooTallNate deleted the swc-plugin/preserve-imports-for-hoisted-steps branch May 5, 2026 21:36
github-actionsBot added a commit that referenced this pull request May 5, 2026
* [swc-plugin] Preserve imports referenced by hoisted nested steps
Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
* [swc-plugin] Namespace nested step IDs under non-exported workflow functions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.
* [swc-plugin] Namespace nested step IDs across all workflow declaration shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
Signed-off-by: Nathan Rajlich <n@n8.io>
@github-actions

Copy link
Copy Markdown
Contributor

Backport PR opened against stable: #1946. Merge conflicts were resolved by AI — please review carefully.

TooTallNate added a commit that referenced this pull request May 22, 2026
…) (#1946)
* [swc-plugin] Preserve imports referenced by hoisted nested steps
Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
* [swc-plugin] Namespace nested step IDs under non-exported workflow functions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.
* [swc-plugin] Namespace nested step IDs across all workflow declaration shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
Signed-off-by: Nathan Rajlich <n@n8.io>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Nathan Rajlich <n@n8.io>
@github-actionsgithub-actionsBot mentioned this pull request May 22, 2026
TooTallNate added a commit that referenced this pull request May 22, 2026
The fixture was introduced by the backport of #1935 (#1945) with the
pre-namespacing step ID "step//./input//step" in the __internal_workflows
manifest comment. The subsequent backport of #1944 (#1946) shipped the
namespacing fix in lib.rs but did not update this fixture, since on main
the two PRs landed in the reverse order and #1944's diff already covered
the fixture there.
Update the expected output to match what the plugin now emits:
"step//./input//outer/step" — same value already present in main.
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.

3 participants

@TooTallNate@karthikscale3
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

[swc-plugin] Preserve imports referenced by hoisted nested steps - #1944

Merged
TooTallNate merged 3 commits into
mainfrom
swc-plugin/preserve-imports-for-hoisted-steps
May 5, 2026
Merged

[swc-plugin] Preserve imports referenced by hoisted nested steps#1944
TooTallNate merged 3 commits into
mainfrom
swc-plugin/preserve-imports-for-hoisted-steps

Conversation

@TooTallNate

Copy link
Copy Markdown
Member

Summary

Fixes a bug in the SWC plugin where step-mode bundles dropped module-level imports that were referenced by step functions hoisted out of workflow bodies, causing a ReferenceError at runtime.

Root Cause

Ordering bug in the transform pipeline:

  1. StepTransform::visit_mut_module_items runs and, at the end, invokes remove_dead_code, which strips any import not referenced by current top-level code.
  2. StepTransform::visit_mut_program then hoists nested step functions out of workflow bodies onto the module top level (e.g. var _anonymousStep0 = async (input) => db.query(input.query);).
  3. The hoisted body references db, but the import was already deleted in step 1.

This only affected steps nested inside workflow function bodies — top-level steps already worked because their bodies were inlined in items before DCE ran. Three pre-existing fixtures (nested-step-with-closure, nested-steps-in-object-constructor, factory-with-step-method) had committed buggy outputs that this change corrects.

For example, given:

import{db}from'./db';asyncfunctionw(){'use workflow';constagent=newWorkflowAgent({tools: ()=>({queryDatabase: tool({execute: async(input)=>{'use step';returndb.query(input.query);},}),}),});}

The previous step-mode output omitted import { db } from './db'; while still emitting var _anonymousStep0 = async (input) => db.query(input.query);.

Fix

In packages/swc-plugin-workflow/transform/src/lib.rs:

  • Removed the early remove_dead_code call from the end of visit_mut_module_items.
  • Added a single remove_dead_code(&mut module.body) call in visit_mut_program, after nested step hoisting completes (right before metadata-comment insertion).

Verification

  • Added regression fixture tests/fixture/nested-step-references-module-import/ covering both kept-imports (used by hoisted step) and stripped-imports (truly unused, or only used by replaced workflow body).
  • All 124 SWC fixture tests pass.
  • Three pre-existing fixtures had their output-step.js files updated to now correctly include the imports their hoisted steps reference.
  • spec.md already documented the desired behavior — no spec change needed; this is purely an implementation conformance fix.

Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
CopilotAI review requested due to automatic review settings May 5, 2026 20:21
@vercel

vercelBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

@changeset-bot

changeset-botBot commented May 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9d132e5

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

This PR includes changesets to release 19 packages
NameType
@workflow/swc-pluginPatch
@workflow/astroPatch
@workflow/buildersPatch
@workflow/cliPatch
@workflow/nestPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
tarballsPatch
workflowPatch
@workflow/vitePatch
@workflow/vitestPatch
@workflow/world-testingPatch
@workflow/nuxtPatch
@workflow/aiPatch
@workflow/corePatch
@workflow/web-sharedPatch
@workflow/webPatch

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

@github-actions

github-actionsBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production120002191419
✅ 💻 Local Development158702191806
✅ 📦 Local Production158702191806
✅ 🐘 Local Postgres158702191806
✅ 🪟 Windows12900129
✅ 📋 Other7270176903
Total6817010527869

Details by Category

✅ ▲ Vercel Production
AppPassedFailedSkipped
✅ astro103026
✅ example103026
✅ express103026
✅ fastify103026
✅ hono103026
✅ nextjs-turbopack12702
✅ nextjs-webpack12702
✅ nitro103026
✅ nuxt103026
✅ sveltekit12207
✅ vite103026
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack12900
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable104025
✅ e2e-local-dev-tanstack-start-104025
✅ e2e-local-postgres-nest-stable104025
✅ e2e-local-postgres-tanstack-start-104025
✅ e2e-local-prod-nest-stable104025
✅ e2e-local-prod-tanstack-start-104025
✅ e2e-vercel-prod-tanstack-start103026

📋 View full workflow run

@github-actions

github-actionsBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

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

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.033s (-22.7% 🟢)1.005s (~)0.972s101.00x
💻 LocalExpress0.036s (-19.2% 🟢)1.006s (~)0.970s101.08x
🐘 PostgresExpress0.045s (-21.7% 🟢)1.011s (~)0.965s101.36x
💻 LocalNext.js (Turbopack)0.049s1.005s0.956s101.47x
🐘 PostgresNitro0.051s (-47.0% 🟢)1.011s (-3.1%)0.961s101.52x
🌐 RedisNext.js (Turbopack)0.052s1.005s0.953s101.56x
🐘 PostgresNext.js (Turbopack)0.057s1.011s0.954s101.71x
🌐 MongoDBNext.js (Turbopack)0.129s1.007s0.879s103.86x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro0.220s (-46.4% 🟢)2.151s (-14.3% 🟢)1.931s101.00x
▲ VercelNext.js (Turbopack)1.154s (+359.0% 🔺)2.852s (+22.3% 🔺)1.698s105.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Express1.075s (-4.5%)2.007s (~)0.931s101.00x
💻 LocalNitro1.075s (-5.0%)2.006s (~)0.931s101.00x
🐘 PostgresNitro1.083s (-5.0%)2.009s (~)0.926s101.01x
🐘 PostgresExpress1.084s (-5.4% 🟢)2.009s (~)0.925s101.01x
💻 LocalNext.js (Turbopack)1.110s2.006s0.896s101.03x
🌐 RedisNext.js (Turbopack)1.111s2.006s0.895s101.03x
🐘 PostgresNext.js (Turbopack)1.129s2.008s0.879s101.05x
🌐 MongoDBNext.js (Turbopack)1.169s2.009s0.840s101.09x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro1.608s (-58.7% 🟢)3.463s (-41.4% 🟢)1.855s101.00x
▲ VercelNext.js (Turbopack)3.023s (+48.6% 🔺)4.583s (+19.6% 🔺)1.560s101.88x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro10.404s (-4.9%)11.023s (~)0.618s31.00x
🐘 PostgresExpress10.408s (-5.1% 🟢)11.018s (~)0.611s31.00x
🐘 PostgresNitro10.419s (-4.2%)11.016s (~)0.597s31.00x
💻 LocalExpress10.424s (-4.6%)11.022s (~)0.598s31.00x
🐘 PostgresNext.js (Turbopack)10.657s11.016s0.359s31.02x
💻 LocalNext.js (Turbopack)10.669s11.021s0.353s31.03x
🌐 RedisNext.js (Turbopack)10.691s11.022s0.332s31.03x
🌐 MongoDBNext.js (Turbopack)10.894s11.352s0.458s31.05x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro13.342s (-43.8% 🟢)14.917s (-40.6% 🟢)1.575s31.00x
▲ VercelNext.js (Turbopack)13.784s (-20.4% 🟢)15.604s (-19.6% 🟢)1.821s21.03x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express13.447s (-7.8% 🟢)14.017s (-6.7% 🟢)0.570s51.00x
🐘 PostgresNitro13.451s (-7.8% 🟢)14.015s (-6.7% 🟢)0.565s51.00x
💻 LocalNitro13.507s (-10.3% 🟢)14.027s (-12.5% 🟢)0.520s51.00x
💻 LocalExpress13.523s (-9.7% 🟢)14.028s (-6.7% 🟢)0.505s51.01x
💻 LocalNext.js (Turbopack)14.061s14.828s0.767s51.05x
🌐 RedisNext.js (Turbopack)14.100s15.029s0.929s41.05x
🐘 PostgresNext.js (Turbopack)14.112s15.017s0.905s41.05x
🌐 MongoDBNext.js (Turbopack)14.354s15.026s0.672s41.07x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro21.643s (-66.4% 🟢)23.304s (-65.0% 🟢)1.660s31.00x
▲ VercelNext.js (Turbopack)23.990s (-54.4% 🟢)25.981s (-52.4% 🟢)1.991s31.11x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express11.854s (-15.4% 🟢)12.015s (-17.7% 🟢)0.161s81.00x
💻 LocalNitro11.930s (-28.9% 🟢)12.022s (-29.4% 🟢)0.092s81.01x
🐘 PostgresNitro11.936s (-14.5% 🟢)12.266s (-14.3% 🟢)0.330s81.01x
💻 LocalExpress12.068s (-27.3% 🟢)12.774s (-25.0% 🟢)0.706s81.02x
🌐 RedisNext.js (Turbopack)12.966s13.310s0.344s71.09x
💻 LocalNext.js (Turbopack)13.010s13.167s0.157s71.10x
🐘 PostgresNext.js (Turbopack)13.305s14.016s0.710s71.12x
🌐 MongoDBNext.js (Turbopack)13.338s14.023s0.684s71.13x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro32.625s (-92.3% 🟢)34.494s (-91.9% 🟢)1.869s31.00x
▲ VercelNext.js (Turbopack)35.758s (-90.9% 🟢)37.455s (-90.5% 🟢)1.697s31.10x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.146s (-10.1% 🟢)2.007s (~)0.861s151.00x
🐘 PostgresExpress1.149s (-8.8% 🟢)2.007s (~)0.857s151.00x
💻 LocalNitro1.186s (-27.3% 🟢)2.006s (-3.3%)0.820s151.04x
💻 LocalExpress1.195s (-19.7% 🟢)2.006s (~)0.811s151.04x
🐘 PostgresNext.js (Turbopack)1.235s2.007s0.772s151.08x
🌐 RedisNext.js (Turbopack)1.254s2.006s0.752s151.09x
💻 LocalNext.js (Turbopack)1.292s2.006s0.714s151.13x
🌐 MongoDBNext.js (Turbopack)2.028s2.735s0.707s111.77x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.906s (+3.1%)4.524s (+4.7%)1.618s71.00x
▲ VercelNext.js (Turbopack)4.911s (+44.6% 🔺)6.214s (+26.0% 🔺)1.303s51.69x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.219s (-48.4% 🟢)2.008s (-33.3% 🟢)0.789s151.00x
🐘 PostgresNitro1.230s (-47.7% 🟢)2.007s (-33.3% 🟢)0.777s151.01x
🐘 PostgresNext.js (Turbopack)1.355s2.007s0.652s151.11x
💻 LocalNitro1.777s (-43.5% 🟢)2.006s (-48.4% 🟢)0.228s151.46x
💻 LocalNext.js (Turbopack)1.824s2.006s0.183s151.50x
💻 LocalExpress1.879s (-36.4% 🟢)2.223s (-35.6% 🟢)0.344s141.54x
🌐 RedisNext.js (Turbopack)2.358s3.008s0.650s101.93x
🌐 MongoDBNext.js (Turbopack)3.576s4.009s0.433s82.93x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.582s (-11.6% 🟢)5.158s (-12.9% 🟢)1.577s71.00x
▲ VercelNext.js (Turbopack)5.608s (-21.0% 🟢)7.256s (-18.5% 🟢)1.648s51.57x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.367s (-60.8% 🟢)2.007s (-49.9% 🟢)0.640s151.00x
🐘 PostgresNitro1.376s (-60.5% 🟢)2.007s (-49.9% 🟢)0.632s151.01x
🐘 PostgresNext.js (Turbopack)1.639s2.074s0.435s151.20x
🌐 RedisNext.js (Turbopack)3.586s4.010s0.423s82.62x
💻 LocalNitro5.274s (-36.8% 🟢)5.846s (-35.2% 🟢)0.572s63.86x
💻 LocalExpress5.587s (-33.0% 🟢)6.213s (-31.2% 🟢)0.626s54.09x
💻 LocalNext.js (Turbopack)5.748s6.213s0.465s54.20x
🌐 MongoDBNext.js (Turbopack)6.301s7.013s0.712s54.61x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.978s (+69.6% 🔺)8.125s (+46.8% 🔺)2.147s41.00x
▲ VercelNext.js (Turbopack)7.377s (-17.3% 🟢)9.561s (-12.8% 🟢)2.184s41.23x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.150s (-8.5% 🟢)2.008s (~)0.858s151.00x
🐘 PostgresNitro1.169s (-7.0% 🟢)2.008s (~)0.839s151.02x
🐘 PostgresNext.js (Turbopack)1.218s2.008s0.790s151.06x
🌐 RedisNext.js (Turbopack)1.240s2.006s0.766s151.08x
💻 LocalNext.js (Turbopack)1.322s2.006s0.684s151.15x
💻 LocalNitro1.398s (-25.1% 🟢)2.006s (-14.3% 🟢)0.608s151.22x
💻 LocalExpress1.423s (-24.8% 🟢)2.006s (-15.1% 🟢)0.583s151.24x
🌐 MongoDBNext.js (Turbopack)2.029s2.675s0.645s121.76x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.689s (+9.3% 🔺)4.494s (+7.8% 🔺)1.805s71.00x
▲ VercelNext.js (Turbopack)3.798s (+29.5% 🔺)5.672s (+22.2% 🔺)1.874s61.41x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.229s (-47.5% 🟢)2.008s (-33.3% 🟢)0.779s151.00x
🐘 PostgresNitro1.247s (-46.7% 🟢)2.008s (-33.3% 🟢)0.760s151.02x
🐘 PostgresNext.js (Turbopack)1.386s2.008s0.622s151.13x
💻 LocalExpress2.079s (-33.6% 🟢)2.510s (-33.3% 🟢)0.430s121.69x
💻 LocalNext.js (Turbopack)2.117s2.735s0.617s111.72x
💻 LocalNitro2.169s (-29.2% 🟢)2.593s (-33.3% 🟢)0.424s121.77x
🌐 RedisNext.js (Turbopack)2.343s3.008s0.665s101.91x
🌐 MongoDBNext.js (Turbopack)3.579s4.009s0.430s82.91x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.315s (+2.5%)4.910s (-3.3%)1.595s71.00x
▲ VercelNext.js (Turbopack)5.136s (+63.4% 🔺)7.036s (+55.6% 🔺)1.901s51.55x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.377s (-60.4% 🟢)2.007s (-49.9% 🟢)0.630s151.00x
🐘 PostgresExpress1.386s (-60.4% 🟢)2.008s (-49.9% 🟢)0.622s151.01x
🐘 PostgresNext.js (Turbopack)1.637s2.007s0.370s151.19x
🌐 RedisNext.js (Turbopack)3.635s4.009s0.374s82.64x
💻 LocalNitro5.492s (-39.9% 🟢)6.214s (-38.0% 🟢)0.722s53.99x
💻 LocalNext.js (Turbopack)5.810s6.413s0.603s54.22x
💻 LocalExpress5.859s (-33.4% 🟢)6.616s (-28.7% 🟢)0.757s54.25x
🌐 MongoDBNext.js (Turbopack)6.297s7.013s0.716s54.57x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)6.088s (-9.9% 🟢)8.239s (-3.6%)2.151s41.00x
▲ VercelNitro6.546s (+28.5% 🔺)8.394s (+23.1% 🔺)1.849s41.08x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

workflow with 10 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.440s (-46.4% 🟢)1.006s (~)0.566s601.00x
🐘 PostgresExpress0.454s (-45.8% 🟢)1.006s (-1.7%)0.552s601.03x
💻 LocalExpress0.504s (-48.8% 🟢)1.005s (-6.6% 🟢)0.500s601.15x
💻 LocalNitro0.524s (-46.5% 🟢)1.022s (-6.6% 🟢)0.498s591.19x
🌐 RedisNext.js (Turbopack)0.617s1.004s0.388s601.40x
🐘 PostgresNext.js (Turbopack)0.665s1.006s0.341s601.51x
💻 LocalNext.js (Turbopack)0.726s1.004s0.278s601.65x
🌐 MongoDBNext.js (Turbopack)0.744s1.006s0.262s601.69x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.295s (-76.0% 🟢)7.121s (-70.4% 🟢)1.826s91.00x
▲ VercelNext.js (Turbopack)6.625s (-54.3% 🟢)8.457s (-47.4% 🟢)1.832s81.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.015s (-47.4% 🟢)1.532s (-27.1% 🟢)0.518s591.00x
🐘 PostgresExpress1.052s (-46.8% 🟢)1.632s (-27.7% 🟢)0.580s561.04x
💻 LocalNitro1.204s (-60.3% 🟢)2.006s (-46.6% 🟢)0.801s451.19x
💻 LocalExpress1.286s (-57.4% 🟢)2.006s (-44.0% 🟢)0.720s451.27x
🌐 RedisNext.js (Turbopack)1.476s2.006s0.529s451.46x
🐘 PostgresNext.js (Turbopack)1.585s2.007s0.423s451.56x
💻 LocalNext.js (Turbopack)1.764s2.006s0.241s451.74x
🌐 MongoDBNext.js (Turbopack)1.840s2.007s0.168s451.81x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro12.861s (-67.4% 🟢)14.586s (-64.7% 🟢)1.725s71.00x
▲ VercelNext.js (Turbopack)16.086s (-67.7% 🟢)18.350s (-64.5% 🟢)2.264s51.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 50 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro2.063s (-49.7% 🟢)2.549s (-44.6% 🟢)0.486s481.00x
🐘 PostgresExpress2.126s (-46.7% 🟢)2.719s (-37.8% 🟢)0.592s451.03x
💻 LocalNitro2.678s (-71.2% 🟢)3.008s (-70.0% 🟢)0.330s401.30x
💻 LocalExpress2.803s (-69.6% 🟢)3.033s (-69.7% 🟢)0.230s401.36x
🌐 RedisNext.js (Turbopack)2.963s3.135s0.173s391.44x
🐘 PostgresNext.js (Turbopack)3.131s4.008s0.877s301.52x
💻 LocalNext.js (Turbopack)3.767s4.007s0.240s301.83x
🌐 MongoDBNext.js (Turbopack)4.174s5.012s0.838s242.02x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro40.280s (-58.4% 🟢)42.530s (-56.8% 🟢)2.250s31.00x
▲ VercelNext.js (Turbopack)46.873s (-56.3% 🟢)48.931s (-55.1% 🟢)2.058s31.16x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 10 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.187s (-33.9% 🟢)1.006s (~)0.818s601.00x
🐘 PostgresExpress0.190s (-32.8% 🟢)1.006s (~)0.816s601.01x
🐘 PostgresNext.js (Turbopack)0.236s1.006s0.770s601.26x
🌐 RedisNext.js (Turbopack)0.242s1.004s0.762s601.30x
💻 LocalNitro0.469s (-22.5% 🟢)1.021s (~)0.553s592.50x
💻 LocalExpress0.483s (-13.8% 🟢)1.005s (~)0.522s602.58x
💻 LocalNext.js (Turbopack)0.554s1.005s0.451s602.96x
🌐 MongoDBNext.js (Turbopack)1.030s1.825s0.794s335.50x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.619s (+57.7% 🔺)4.178s (+24.7% 🔺)1.559s151.00x
▲ VercelNext.js (Turbopack)3.871s (+91.4% 🔺)5.504s (+45.1% 🔺)1.633s121.48x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.315s (-36.6% 🟢)1.006s (~)0.691s901.00x
🐘 PostgresExpress0.325s (-36.3% 🟢)1.007s (~)0.682s901.03x
🌐 RedisNext.js (Turbopack)0.410s1.004s0.594s901.30x
🐘 PostgresNext.js (Turbopack)0.458s1.006s0.548s901.45x
💻 LocalNitro2.270s (-10.6% 🟢)2.944s (-2.2%)0.675s317.21x
💻 LocalExpress2.282s (-9.2% 🟢)3.009s (~)0.727s307.25x
💻 LocalNext.js (Turbopack)2.466s3.042s0.576s307.84x
🌐 MongoDBNext.js (Turbopack)2.605s3.007s0.402s308.28x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)8.211s (+132.3% 🔺)9.775s (+88.2% 🔺)1.564s101.00x
▲ VercelNitro9.758s (+202.5% 🔺)11.351s (+135.4% 🔺)1.593s81.19x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

workflow with 50 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.652s (-17.5% 🟢)1.006s (~)0.354s1201.00x
🐘 PostgresExpress0.697s (-14.9% 🟢)1.007s (-1.0%)0.310s1201.07x
🌐 RedisNext.js (Turbopack)0.755s1.004s0.249s1201.16x
🐘 PostgresNext.js (Turbopack)0.944s1.340s0.397s901.45x
🌐 MongoDBNext.js (Turbopack)5.389s6.013s0.624s208.27x
💻 LocalNitro10.289s (-8.1% 🟢)10.781s (-7.6% 🟢)0.492s1215.78x
💻 LocalExpress11.054s (-1.2%)11.668s (-2.3%)0.615s1116.96x
💻 LocalNext.js (Turbopack)11.576s12.233s0.657s1017.76x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)19.155s (+85.5% 🔺)21.092s (+71.7% 🔺)1.938s61.00x
▲ VercelNitro23.620s (+205.8% 🔺)25.372s (+169.9% 🔺)1.753s51.23x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.133s (+452.2% 🔺)1.997s (+100.0% 🔺)0.001s (-18.8% 🟢)2.011s (+98.8% 🔺)0.878s101.00x
🐘 PostgresNitro1.140s (+456.1% 🔺)1.997s (+99.8% 🔺)0.001s (-13.3% 🟢)2.011s (+98.8% 🔺)0.871s101.01x
💻 LocalNitro1.141s (+434.1% 🔺)2.005s (+99.6% 🔺)0.013s (+1.6%)2.021s (+98.3% 🔺)0.879s101.01x
💻 LocalExpress1.142s (+473.8% 🔺)2.006s (+99.7% 🔺)0.013s (+4.1%)2.021s (+98.5% 🔺)0.878s101.01x
💻 LocalNext.js (Turbopack)1.176s2.004s0.012s2.020s0.844s101.04x
🐘 PostgresNext.js (Turbopack)1.196s2.001s0.002s2.011s0.816s101.06x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.149s (-43.9% 🟢)3.058s (-42.1% 🟢)1.931s (+160.2% 🔺)5.669s (-12.6% 🟢)3.520s101.00x
▲ VercelNext.js (Turbopack)4.815s (-29.7% 🟢)5.037s (-41.8% 🟢)0.879s (+39.1% 🔺)7.516s (-23.2% 🟢)2.701s102.24x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

stream pipeline with 5 transform steps (1MB)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.522s (+143.9% 🔺)1.999s (+98.6% 🔺)0.004s (-9.7% 🟢)2.025s (+98.1% 🔺)0.503s301.00x
🐘 PostgresExpress1.563s (+148.0% 🔺)2.005s (+99.2% 🔺)0.004s (-4.3%)2.025s (+98.0% 🔺)0.463s301.03x
💻 LocalNext.js (Turbopack)1.664s2.010s0.009s2.023s0.359s301.09x
🐘 PostgresNext.js (Turbopack)1.669s2.009s0.004s2.024s0.355s301.10x
💻 LocalNitro1.705s (+103.2% 🔺)2.011s (+98.7% 🔺)0.009s (-7.0% 🟢)2.201s (+97.2% 🔺)0.496s281.12x
💻 LocalExpress1.755s (+131.8% 🔺)2.012s (+95.6% 🔺)0.011s (+14.6% 🔺)2.204s (+112.0% 🔺)0.449s281.15x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.949s (-79.8% 🟢)7.135s (-76.8% 🟢)0.212s (+89.2% 🔺)7.803s (-75.4% 🟢)1.855s81.00x
▲ VercelNext.js (Turbopack)12.421s (-26.6% 🟢)12.915s (-29.2% 🟢)0.180s (-14.7% 🟢)14.203s (-25.0% 🟢)1.782s52.09x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

10 parallel streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.674s (-30.4% 🟢)1.050s (-15.9% 🟢)0.000s (-15.8% 🟢)1.064s (-15.4% 🟢)0.390s571.00x
🐘 PostgresExpress0.714s (-25.7% 🟢)1.031s (-19.3% 🟢)0.000s (-100.0% 🟢)1.043s (-20.1% 🟢)0.329s581.06x
🐘 PostgresNext.js (Turbopack)0.787s1.035s0.000s1.049s0.262s581.17x
💻 LocalNitro1.303s (+6.6% 🔺)2.015s (~)0.000s (+166.7% 🔺)2.017s (~)0.714s301.93x
💻 LocalExpress1.426s (+16.4% 🔺)2.015s (~)0.000s (-20.0% 🟢)2.018s (~)0.591s302.11x
💻 LocalNext.js (Turbopack)1.611s2.014s0.000s2.197s0.586s282.39x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.728s (+22.2% 🔺)4.649s (+5.8% 🔺)0.001s (+766.7% 🔺)5.068s (+5.4% 🔺)1.340s121.00x
▲ VercelNext.js (Turbopack)7.287s (-28.4% 🟢)7.260s (-37.0% 🟢)0.000s (NaN%)9.165s (-23.9% 🟢)1.878s71.95x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

fan-out fan-in 10 streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.383s (-22.8% 🟢)2.141s (~)0.000s (+100.0% 🔺)2.153s (-1.0%)0.770s281.00x
🐘 PostgresExpress1.504s (-15.1% 🟢)2.097s (-3.7%)0.000s (NaN%)2.131s (-3.1%)0.627s291.09x
🐘 PostgresNext.js (Turbopack)1.667s2.224s0.000s2.233s0.566s271.21x
💻 LocalNext.js (Turbopack)2.804s3.361s0.000s3.365s0.561s182.03x
💻 LocalNitro3.108s (-8.2% 🟢)3.841s (-4.7%)0.000s (-18.0% 🟢)3.843s (-4.8%)0.735s162.25x
💻 LocalExpress3.249s (-6.3% 🟢)3.842s (-4.7%)0.001s (-21.9% 🟢)3.845s (-4.7%)0.596s162.35x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.969s (+45.8% 🔺)7.219s (+34.3% 🔺)0.000s (-100.0% 🟢)7.627s (+31.6% 🔺)1.658s81.00x
▲ VercelNext.js (Turbopack)9.307s (+65.7% 🔺)9.811s (+40.5% 🔺)0.001s (+300.0% 🔺)11.072s (+46.8% 🔺)1.765s61.56x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro15/21
🐘 PostgresNitro12/21
▲ VercelNitro18/21
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express🐘 Postgres19/21
Next.js (Turbopack)🐘 Postgres10/21
Nitro🐘 Postgres17/21
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)
  • Slurp: Time from first byte to complete stream consumption (stream benchmarks only)
  • Wall Time: Total testbench time (trigger workflow + poll for result)
  • Overhead: Testbench overhead (Wall Time - Workflow Time)
  • Samples: Number of benchmark iterations run
  • vs Fastest: How much slower compared to the fastest configuration for this benchmark

Worlds:

  • 💻 Local: In-memory filesystem world (local development)
  • 🐘 Postgres: PostgreSQL database world (local development)
  • ▲ Vercel: Vercel production/preview deployment
  • 🌐 Turso: Community world (local development)
  • 🌐 MongoDB: Community world (local development)
  • 🌐 Redis: Community world (local development)
  • 🌐 Jazz: Community world (local development)

📋 View full workflow run


Some benchmark jobs failed:

  • Local: success
  • Postgres: success
  • Vercel: failure

Check the workflow run for details.

@karthikscale3karthikscale3 left a comment

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.

LGTM. Verified it in the SWC playground.

CopilotAI left a comment

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.

Pull request overview

This PR adjusts the SWC workflow transform so dead-code elimination runs after nested step hoisting, with the goal of preserving module imports that hoisted step bodies still reference in step-mode output.

Changes:

  • Moves remove_dead_code from visit_mut_module_items to the end of visit_mut_program.
  • Updates existing step-mode fixtures whose hoisted steps now correctly retain required imports.
  • Adds a regression fixture covering nested steps that reference module-level imports.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
packages/swc-plugin-workflow/transform/tests/fixture/nested-steps-in-object-constructor/output-step.jsUpdates expected step output to retain an import used by a hoisted nested step.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-with-closure/output-step.jsUpdates expected step output to retain an import referenced from hoisted closure-based steps.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/output-workflow.jsAdds workflow-mode regression output for the new nested-import fixture.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/output-step.jsAdds step-mode regression output showing preserved imports for a hoisted nested step.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/input.jsAdds the new regression input covering nested step references to module imports.
packages/swc-plugin-workflow/transform/tests/fixture/factory-with-step-method/output-step.jsUpdates expected step output to retain an import used by a hoisted step method.
packages/swc-plugin-workflow/transform/src/lib.rsDefers dead-code elimination until after nested step hoisting completes.
.changeset/preserve-imports-used-by-hoisted-steps.mdRecords the patch release note for the SWC plugin fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/swc-plugin-workflow/transform/src/lib.rs
…nctions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.

CopilotAI left a comment

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.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/swc-plugin-workflow/transform/src/lib.rs
Comment thread.changeset/preserve-imports-used-by-hoisted-steps.md Outdated
…n shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
@TooTallNate
TooTallNate enabled auto-merge (squash) May 5, 2026 21:34
@TooTallNate
TooTallNate merged commit 1d4f83a into mainMay 5, 2026
113 of 114 checks passed
@TooTallNate
TooTallNate deleted the swc-plugin/preserve-imports-for-hoisted-steps branch May 5, 2026 21:36
github-actionsBot added a commit that referenced this pull request May 5, 2026
* [swc-plugin] Preserve imports referenced by hoisted nested steps
Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
* [swc-plugin] Namespace nested step IDs under non-exported workflow functions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.
* [swc-plugin] Namespace nested step IDs across all workflow declaration shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
Signed-off-by: Nathan Rajlich <n@n8.io>
@github-actions

Copy link
Copy Markdown
Contributor

Backport PR opened against stable: #1946. Merge conflicts were resolved by AI — please review carefully.

TooTallNate added a commit that referenced this pull request May 22, 2026
…) (#1946)
* [swc-plugin] Preserve imports referenced by hoisted nested steps
Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
* [swc-plugin] Namespace nested step IDs under non-exported workflow functions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.
* [swc-plugin] Namespace nested step IDs across all workflow declaration shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
Signed-off-by: Nathan Rajlich <n@n8.io>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Nathan Rajlich <n@n8.io>
@github-actionsgithub-actionsBot mentioned this pull request May 22, 2026
TooTallNate added a commit that referenced this pull request May 22, 2026
The fixture was introduced by the backport of #1935 (#1945) with the
pre-namespacing step ID "step//./input//step" in the __internal_workflows
manifest comment. The subsequent backport of #1944 (#1946) shipped the
namespacing fix in lib.rs but did not update this fixture, since on main
the two PRs landed in the reverse order and #1944's diff already covered
the fixture there.
Update the expected output to match what the plugin now emits:
"step//./input//outer/step" — same value already present in main.
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.

3 participants

@TooTallNate@karthikscale3
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

[swc-plugin] Preserve imports referenced by hoisted nested steps - #1944

Merged
TooTallNate merged 3 commits into
mainfrom
swc-plugin/preserve-imports-for-hoisted-steps
May 5, 2026
Merged

[swc-plugin] Preserve imports referenced by hoisted nested steps#1944
TooTallNate merged 3 commits into
mainfrom
swc-plugin/preserve-imports-for-hoisted-steps

Conversation

@TooTallNate

Copy link
Copy Markdown
Member

Summary

Fixes a bug in the SWC plugin where step-mode bundles dropped module-level imports that were referenced by step functions hoisted out of workflow bodies, causing a ReferenceError at runtime.

Root Cause

Ordering bug in the transform pipeline:

  1. StepTransform::visit_mut_module_items runs and, at the end, invokes remove_dead_code, which strips any import not referenced by current top-level code.
  2. StepTransform::visit_mut_program then hoists nested step functions out of workflow bodies onto the module top level (e.g. var _anonymousStep0 = async (input) => db.query(input.query);).
  3. The hoisted body references db, but the import was already deleted in step 1.

This only affected steps nested inside workflow function bodies — top-level steps already worked because their bodies were inlined in items before DCE ran. Three pre-existing fixtures (nested-step-with-closure, nested-steps-in-object-constructor, factory-with-step-method) had committed buggy outputs that this change corrects.

For example, given:

import{db}from'./db';asyncfunctionw(){'use workflow';constagent=newWorkflowAgent({tools: ()=>({queryDatabase: tool({execute: async(input)=>{'use step';returndb.query(input.query);},}),}),});}

The previous step-mode output omitted import { db } from './db'; while still emitting var _anonymousStep0 = async (input) => db.query(input.query);.

Fix

In packages/swc-plugin-workflow/transform/src/lib.rs:

  • Removed the early remove_dead_code call from the end of visit_mut_module_items.
  • Added a single remove_dead_code(&mut module.body) call in visit_mut_program, after nested step hoisting completes (right before metadata-comment insertion).

Verification

  • Added regression fixture tests/fixture/nested-step-references-module-import/ covering both kept-imports (used by hoisted step) and stripped-imports (truly unused, or only used by replaced workflow body).
  • All 124 SWC fixture tests pass.
  • Three pre-existing fixtures had their output-step.js files updated to now correctly include the imports their hoisted steps reference.
  • spec.md already documented the desired behavior — no spec change needed; this is purely an implementation conformance fix.

Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
CopilotAI review requested due to automatic review settings May 5, 2026 20:21
@vercel

vercelBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

@changeset-bot

changeset-botBot commented May 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9d132e5

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

This PR includes changesets to release 19 packages
NameType
@workflow/swc-pluginPatch
@workflow/astroPatch
@workflow/buildersPatch
@workflow/cliPatch
@workflow/nestPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
tarballsPatch
workflowPatch
@workflow/vitePatch
@workflow/vitestPatch
@workflow/world-testingPatch
@workflow/nuxtPatch
@workflow/aiPatch
@workflow/corePatch
@workflow/web-sharedPatch
@workflow/webPatch

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

@github-actions

github-actionsBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production120002191419
✅ 💻 Local Development158702191806
✅ 📦 Local Production158702191806
✅ 🐘 Local Postgres158702191806
✅ 🪟 Windows12900129
✅ 📋 Other7270176903
Total6817010527869

Details by Category

✅ ▲ Vercel Production
AppPassedFailedSkipped
✅ astro103026
✅ example103026
✅ express103026
✅ fastify103026
✅ hono103026
✅ nextjs-turbopack12702
✅ nextjs-webpack12702
✅ nitro103026
✅ nuxt103026
✅ sveltekit12207
✅ vite103026
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack12900
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable104025
✅ e2e-local-dev-tanstack-start-104025
✅ e2e-local-postgres-nest-stable104025
✅ e2e-local-postgres-tanstack-start-104025
✅ e2e-local-prod-nest-stable104025
✅ e2e-local-prod-tanstack-start-104025
✅ e2e-vercel-prod-tanstack-start103026

📋 View full workflow run

@github-actions

github-actionsBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

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

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.033s (-22.7% 🟢)1.005s (~)0.972s101.00x
💻 LocalExpress0.036s (-19.2% 🟢)1.006s (~)0.970s101.08x
🐘 PostgresExpress0.045s (-21.7% 🟢)1.011s (~)0.965s101.36x
💻 LocalNext.js (Turbopack)0.049s1.005s0.956s101.47x
🐘 PostgresNitro0.051s (-47.0% 🟢)1.011s (-3.1%)0.961s101.52x
🌐 RedisNext.js (Turbopack)0.052s1.005s0.953s101.56x
🐘 PostgresNext.js (Turbopack)0.057s1.011s0.954s101.71x
🌐 MongoDBNext.js (Turbopack)0.129s1.007s0.879s103.86x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro0.220s (-46.4% 🟢)2.151s (-14.3% 🟢)1.931s101.00x
▲ VercelNext.js (Turbopack)1.154s (+359.0% 🔺)2.852s (+22.3% 🔺)1.698s105.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Express1.075s (-4.5%)2.007s (~)0.931s101.00x
💻 LocalNitro1.075s (-5.0%)2.006s (~)0.931s101.00x
🐘 PostgresNitro1.083s (-5.0%)2.009s (~)0.926s101.01x
🐘 PostgresExpress1.084s (-5.4% 🟢)2.009s (~)0.925s101.01x
💻 LocalNext.js (Turbopack)1.110s2.006s0.896s101.03x
🌐 RedisNext.js (Turbopack)1.111s2.006s0.895s101.03x
🐘 PostgresNext.js (Turbopack)1.129s2.008s0.879s101.05x
🌐 MongoDBNext.js (Turbopack)1.169s2.009s0.840s101.09x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro1.608s (-58.7% 🟢)3.463s (-41.4% 🟢)1.855s101.00x
▲ VercelNext.js (Turbopack)3.023s (+48.6% 🔺)4.583s (+19.6% 🔺)1.560s101.88x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro10.404s (-4.9%)11.023s (~)0.618s31.00x
🐘 PostgresExpress10.408s (-5.1% 🟢)11.018s (~)0.611s31.00x
🐘 PostgresNitro10.419s (-4.2%)11.016s (~)0.597s31.00x
💻 LocalExpress10.424s (-4.6%)11.022s (~)0.598s31.00x
🐘 PostgresNext.js (Turbopack)10.657s11.016s0.359s31.02x
💻 LocalNext.js (Turbopack)10.669s11.021s0.353s31.03x
🌐 RedisNext.js (Turbopack)10.691s11.022s0.332s31.03x
🌐 MongoDBNext.js (Turbopack)10.894s11.352s0.458s31.05x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro13.342s (-43.8% 🟢)14.917s (-40.6% 🟢)1.575s31.00x
▲ VercelNext.js (Turbopack)13.784s (-20.4% 🟢)15.604s (-19.6% 🟢)1.821s21.03x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express13.447s (-7.8% 🟢)14.017s (-6.7% 🟢)0.570s51.00x
🐘 PostgresNitro13.451s (-7.8% 🟢)14.015s (-6.7% 🟢)0.565s51.00x
💻 LocalNitro13.507s (-10.3% 🟢)14.027s (-12.5% 🟢)0.520s51.00x
💻 LocalExpress13.523s (-9.7% 🟢)14.028s (-6.7% 🟢)0.505s51.01x
💻 LocalNext.js (Turbopack)14.061s14.828s0.767s51.05x
🌐 RedisNext.js (Turbopack)14.100s15.029s0.929s41.05x
🐘 PostgresNext.js (Turbopack)14.112s15.017s0.905s41.05x
🌐 MongoDBNext.js (Turbopack)14.354s15.026s0.672s41.07x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro21.643s (-66.4% 🟢)23.304s (-65.0% 🟢)1.660s31.00x
▲ VercelNext.js (Turbopack)23.990s (-54.4% 🟢)25.981s (-52.4% 🟢)1.991s31.11x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express11.854s (-15.4% 🟢)12.015s (-17.7% 🟢)0.161s81.00x
💻 LocalNitro11.930s (-28.9% 🟢)12.022s (-29.4% 🟢)0.092s81.01x
🐘 PostgresNitro11.936s (-14.5% 🟢)12.266s (-14.3% 🟢)0.330s81.01x
💻 LocalExpress12.068s (-27.3% 🟢)12.774s (-25.0% 🟢)0.706s81.02x
🌐 RedisNext.js (Turbopack)12.966s13.310s0.344s71.09x
💻 LocalNext.js (Turbopack)13.010s13.167s0.157s71.10x
🐘 PostgresNext.js (Turbopack)13.305s14.016s0.710s71.12x
🌐 MongoDBNext.js (Turbopack)13.338s14.023s0.684s71.13x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro32.625s (-92.3% 🟢)34.494s (-91.9% 🟢)1.869s31.00x
▲ VercelNext.js (Turbopack)35.758s (-90.9% 🟢)37.455s (-90.5% 🟢)1.697s31.10x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.146s (-10.1% 🟢)2.007s (~)0.861s151.00x
🐘 PostgresExpress1.149s (-8.8% 🟢)2.007s (~)0.857s151.00x
💻 LocalNitro1.186s (-27.3% 🟢)2.006s (-3.3%)0.820s151.04x
💻 LocalExpress1.195s (-19.7% 🟢)2.006s (~)0.811s151.04x
🐘 PostgresNext.js (Turbopack)1.235s2.007s0.772s151.08x
🌐 RedisNext.js (Turbopack)1.254s2.006s0.752s151.09x
💻 LocalNext.js (Turbopack)1.292s2.006s0.714s151.13x
🌐 MongoDBNext.js (Turbopack)2.028s2.735s0.707s111.77x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.906s (+3.1%)4.524s (+4.7%)1.618s71.00x
▲ VercelNext.js (Turbopack)4.911s (+44.6% 🔺)6.214s (+26.0% 🔺)1.303s51.69x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.219s (-48.4% 🟢)2.008s (-33.3% 🟢)0.789s151.00x
🐘 PostgresNitro1.230s (-47.7% 🟢)2.007s (-33.3% 🟢)0.777s151.01x
🐘 PostgresNext.js (Turbopack)1.355s2.007s0.652s151.11x
💻 LocalNitro1.777s (-43.5% 🟢)2.006s (-48.4% 🟢)0.228s151.46x
💻 LocalNext.js (Turbopack)1.824s2.006s0.183s151.50x
💻 LocalExpress1.879s (-36.4% 🟢)2.223s (-35.6% 🟢)0.344s141.54x
🌐 RedisNext.js (Turbopack)2.358s3.008s0.650s101.93x
🌐 MongoDBNext.js (Turbopack)3.576s4.009s0.433s82.93x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.582s (-11.6% 🟢)5.158s (-12.9% 🟢)1.577s71.00x
▲ VercelNext.js (Turbopack)5.608s (-21.0% 🟢)7.256s (-18.5% 🟢)1.648s51.57x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.367s (-60.8% 🟢)2.007s (-49.9% 🟢)0.640s151.00x
🐘 PostgresNitro1.376s (-60.5% 🟢)2.007s (-49.9% 🟢)0.632s151.01x
🐘 PostgresNext.js (Turbopack)1.639s2.074s0.435s151.20x
🌐 RedisNext.js (Turbopack)3.586s4.010s0.423s82.62x
💻 LocalNitro5.274s (-36.8% 🟢)5.846s (-35.2% 🟢)0.572s63.86x
💻 LocalExpress5.587s (-33.0% 🟢)6.213s (-31.2% 🟢)0.626s54.09x
💻 LocalNext.js (Turbopack)5.748s6.213s0.465s54.20x
🌐 MongoDBNext.js (Turbopack)6.301s7.013s0.712s54.61x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.978s (+69.6% 🔺)8.125s (+46.8% 🔺)2.147s41.00x
▲ VercelNext.js (Turbopack)7.377s (-17.3% 🟢)9.561s (-12.8% 🟢)2.184s41.23x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.150s (-8.5% 🟢)2.008s (~)0.858s151.00x
🐘 PostgresNitro1.169s (-7.0% 🟢)2.008s (~)0.839s151.02x
🐘 PostgresNext.js (Turbopack)1.218s2.008s0.790s151.06x
🌐 RedisNext.js (Turbopack)1.240s2.006s0.766s151.08x
💻 LocalNext.js (Turbopack)1.322s2.006s0.684s151.15x
💻 LocalNitro1.398s (-25.1% 🟢)2.006s (-14.3% 🟢)0.608s151.22x
💻 LocalExpress1.423s (-24.8% 🟢)2.006s (-15.1% 🟢)0.583s151.24x
🌐 MongoDBNext.js (Turbopack)2.029s2.675s0.645s121.76x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.689s (+9.3% 🔺)4.494s (+7.8% 🔺)1.805s71.00x
▲ VercelNext.js (Turbopack)3.798s (+29.5% 🔺)5.672s (+22.2% 🔺)1.874s61.41x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.229s (-47.5% 🟢)2.008s (-33.3% 🟢)0.779s151.00x
🐘 PostgresNitro1.247s (-46.7% 🟢)2.008s (-33.3% 🟢)0.760s151.02x
🐘 PostgresNext.js (Turbopack)1.386s2.008s0.622s151.13x
💻 LocalExpress2.079s (-33.6% 🟢)2.510s (-33.3% 🟢)0.430s121.69x
💻 LocalNext.js (Turbopack)2.117s2.735s0.617s111.72x
💻 LocalNitro2.169s (-29.2% 🟢)2.593s (-33.3% 🟢)0.424s121.77x
🌐 RedisNext.js (Turbopack)2.343s3.008s0.665s101.91x
🌐 MongoDBNext.js (Turbopack)3.579s4.009s0.430s82.91x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.315s (+2.5%)4.910s (-3.3%)1.595s71.00x
▲ VercelNext.js (Turbopack)5.136s (+63.4% 🔺)7.036s (+55.6% 🔺)1.901s51.55x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.377s (-60.4% 🟢)2.007s (-49.9% 🟢)0.630s151.00x
🐘 PostgresExpress1.386s (-60.4% 🟢)2.008s (-49.9% 🟢)0.622s151.01x
🐘 PostgresNext.js (Turbopack)1.637s2.007s0.370s151.19x
🌐 RedisNext.js (Turbopack)3.635s4.009s0.374s82.64x
💻 LocalNitro5.492s (-39.9% 🟢)6.214s (-38.0% 🟢)0.722s53.99x
💻 LocalNext.js (Turbopack)5.810s6.413s0.603s54.22x
💻 LocalExpress5.859s (-33.4% 🟢)6.616s (-28.7% 🟢)0.757s54.25x
🌐 MongoDBNext.js (Turbopack)6.297s7.013s0.716s54.57x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)6.088s (-9.9% 🟢)8.239s (-3.6%)2.151s41.00x
▲ VercelNitro6.546s (+28.5% 🔺)8.394s (+23.1% 🔺)1.849s41.08x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

workflow with 10 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.440s (-46.4% 🟢)1.006s (~)0.566s601.00x
🐘 PostgresExpress0.454s (-45.8% 🟢)1.006s (-1.7%)0.552s601.03x
💻 LocalExpress0.504s (-48.8% 🟢)1.005s (-6.6% 🟢)0.500s601.15x
💻 LocalNitro0.524s (-46.5% 🟢)1.022s (-6.6% 🟢)0.498s591.19x
🌐 RedisNext.js (Turbopack)0.617s1.004s0.388s601.40x
🐘 PostgresNext.js (Turbopack)0.665s1.006s0.341s601.51x
💻 LocalNext.js (Turbopack)0.726s1.004s0.278s601.65x
🌐 MongoDBNext.js (Turbopack)0.744s1.006s0.262s601.69x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.295s (-76.0% 🟢)7.121s (-70.4% 🟢)1.826s91.00x
▲ VercelNext.js (Turbopack)6.625s (-54.3% 🟢)8.457s (-47.4% 🟢)1.832s81.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.015s (-47.4% 🟢)1.532s (-27.1% 🟢)0.518s591.00x
🐘 PostgresExpress1.052s (-46.8% 🟢)1.632s (-27.7% 🟢)0.580s561.04x
💻 LocalNitro1.204s (-60.3% 🟢)2.006s (-46.6% 🟢)0.801s451.19x
💻 LocalExpress1.286s (-57.4% 🟢)2.006s (-44.0% 🟢)0.720s451.27x
🌐 RedisNext.js (Turbopack)1.476s2.006s0.529s451.46x
🐘 PostgresNext.js (Turbopack)1.585s2.007s0.423s451.56x
💻 LocalNext.js (Turbopack)1.764s2.006s0.241s451.74x
🌐 MongoDBNext.js (Turbopack)1.840s2.007s0.168s451.81x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro12.861s (-67.4% 🟢)14.586s (-64.7% 🟢)1.725s71.00x
▲ VercelNext.js (Turbopack)16.086s (-67.7% 🟢)18.350s (-64.5% 🟢)2.264s51.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 50 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro2.063s (-49.7% 🟢)2.549s (-44.6% 🟢)0.486s481.00x
🐘 PostgresExpress2.126s (-46.7% 🟢)2.719s (-37.8% 🟢)0.592s451.03x
💻 LocalNitro2.678s (-71.2% 🟢)3.008s (-70.0% 🟢)0.330s401.30x
💻 LocalExpress2.803s (-69.6% 🟢)3.033s (-69.7% 🟢)0.230s401.36x
🌐 RedisNext.js (Turbopack)2.963s3.135s0.173s391.44x
🐘 PostgresNext.js (Turbopack)3.131s4.008s0.877s301.52x
💻 LocalNext.js (Turbopack)3.767s4.007s0.240s301.83x
🌐 MongoDBNext.js (Turbopack)4.174s5.012s0.838s242.02x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro40.280s (-58.4% 🟢)42.530s (-56.8% 🟢)2.250s31.00x
▲ VercelNext.js (Turbopack)46.873s (-56.3% 🟢)48.931s (-55.1% 🟢)2.058s31.16x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 10 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.187s (-33.9% 🟢)1.006s (~)0.818s601.00x
🐘 PostgresExpress0.190s (-32.8% 🟢)1.006s (~)0.816s601.01x
🐘 PostgresNext.js (Turbopack)0.236s1.006s0.770s601.26x
🌐 RedisNext.js (Turbopack)0.242s1.004s0.762s601.30x
💻 LocalNitro0.469s (-22.5% 🟢)1.021s (~)0.553s592.50x
💻 LocalExpress0.483s (-13.8% 🟢)1.005s (~)0.522s602.58x
💻 LocalNext.js (Turbopack)0.554s1.005s0.451s602.96x
🌐 MongoDBNext.js (Turbopack)1.030s1.825s0.794s335.50x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.619s (+57.7% 🔺)4.178s (+24.7% 🔺)1.559s151.00x
▲ VercelNext.js (Turbopack)3.871s (+91.4% 🔺)5.504s (+45.1% 🔺)1.633s121.48x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.315s (-36.6% 🟢)1.006s (~)0.691s901.00x
🐘 PostgresExpress0.325s (-36.3% 🟢)1.007s (~)0.682s901.03x
🌐 RedisNext.js (Turbopack)0.410s1.004s0.594s901.30x
🐘 PostgresNext.js (Turbopack)0.458s1.006s0.548s901.45x
💻 LocalNitro2.270s (-10.6% 🟢)2.944s (-2.2%)0.675s317.21x
💻 LocalExpress2.282s (-9.2% 🟢)3.009s (~)0.727s307.25x
💻 LocalNext.js (Turbopack)2.466s3.042s0.576s307.84x
🌐 MongoDBNext.js (Turbopack)2.605s3.007s0.402s308.28x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)8.211s (+132.3% 🔺)9.775s (+88.2% 🔺)1.564s101.00x
▲ VercelNitro9.758s (+202.5% 🔺)11.351s (+135.4% 🔺)1.593s81.19x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

workflow with 50 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.652s (-17.5% 🟢)1.006s (~)0.354s1201.00x
🐘 PostgresExpress0.697s (-14.9% 🟢)1.007s (-1.0%)0.310s1201.07x
🌐 RedisNext.js (Turbopack)0.755s1.004s0.249s1201.16x
🐘 PostgresNext.js (Turbopack)0.944s1.340s0.397s901.45x
🌐 MongoDBNext.js (Turbopack)5.389s6.013s0.624s208.27x
💻 LocalNitro10.289s (-8.1% 🟢)10.781s (-7.6% 🟢)0.492s1215.78x
💻 LocalExpress11.054s (-1.2%)11.668s (-2.3%)0.615s1116.96x
💻 LocalNext.js (Turbopack)11.576s12.233s0.657s1017.76x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)19.155s (+85.5% 🔺)21.092s (+71.7% 🔺)1.938s61.00x
▲ VercelNitro23.620s (+205.8% 🔺)25.372s (+169.9% 🔺)1.753s51.23x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.133s (+452.2% 🔺)1.997s (+100.0% 🔺)0.001s (-18.8% 🟢)2.011s (+98.8% 🔺)0.878s101.00x
🐘 PostgresNitro1.140s (+456.1% 🔺)1.997s (+99.8% 🔺)0.001s (-13.3% 🟢)2.011s (+98.8% 🔺)0.871s101.01x
💻 LocalNitro1.141s (+434.1% 🔺)2.005s (+99.6% 🔺)0.013s (+1.6%)2.021s (+98.3% 🔺)0.879s101.01x
💻 LocalExpress1.142s (+473.8% 🔺)2.006s (+99.7% 🔺)0.013s (+4.1%)2.021s (+98.5% 🔺)0.878s101.01x
💻 LocalNext.js (Turbopack)1.176s2.004s0.012s2.020s0.844s101.04x
🐘 PostgresNext.js (Turbopack)1.196s2.001s0.002s2.011s0.816s101.06x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.149s (-43.9% 🟢)3.058s (-42.1% 🟢)1.931s (+160.2% 🔺)5.669s (-12.6% 🟢)3.520s101.00x
▲ VercelNext.js (Turbopack)4.815s (-29.7% 🟢)5.037s (-41.8% 🟢)0.879s (+39.1% 🔺)7.516s (-23.2% 🟢)2.701s102.24x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

stream pipeline with 5 transform steps (1MB)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.522s (+143.9% 🔺)1.999s (+98.6% 🔺)0.004s (-9.7% 🟢)2.025s (+98.1% 🔺)0.503s301.00x
🐘 PostgresExpress1.563s (+148.0% 🔺)2.005s (+99.2% 🔺)0.004s (-4.3%)2.025s (+98.0% 🔺)0.463s301.03x
💻 LocalNext.js (Turbopack)1.664s2.010s0.009s2.023s0.359s301.09x
🐘 PostgresNext.js (Turbopack)1.669s2.009s0.004s2.024s0.355s301.10x
💻 LocalNitro1.705s (+103.2% 🔺)2.011s (+98.7% 🔺)0.009s (-7.0% 🟢)2.201s (+97.2% 🔺)0.496s281.12x
💻 LocalExpress1.755s (+131.8% 🔺)2.012s (+95.6% 🔺)0.011s (+14.6% 🔺)2.204s (+112.0% 🔺)0.449s281.15x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.949s (-79.8% 🟢)7.135s (-76.8% 🟢)0.212s (+89.2% 🔺)7.803s (-75.4% 🟢)1.855s81.00x
▲ VercelNext.js (Turbopack)12.421s (-26.6% 🟢)12.915s (-29.2% 🟢)0.180s (-14.7% 🟢)14.203s (-25.0% 🟢)1.782s52.09x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

10 parallel streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.674s (-30.4% 🟢)1.050s (-15.9% 🟢)0.000s (-15.8% 🟢)1.064s (-15.4% 🟢)0.390s571.00x
🐘 PostgresExpress0.714s (-25.7% 🟢)1.031s (-19.3% 🟢)0.000s (-100.0% 🟢)1.043s (-20.1% 🟢)0.329s581.06x
🐘 PostgresNext.js (Turbopack)0.787s1.035s0.000s1.049s0.262s581.17x
💻 LocalNitro1.303s (+6.6% 🔺)2.015s (~)0.000s (+166.7% 🔺)2.017s (~)0.714s301.93x
💻 LocalExpress1.426s (+16.4% 🔺)2.015s (~)0.000s (-20.0% 🟢)2.018s (~)0.591s302.11x
💻 LocalNext.js (Turbopack)1.611s2.014s0.000s2.197s0.586s282.39x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.728s (+22.2% 🔺)4.649s (+5.8% 🔺)0.001s (+766.7% 🔺)5.068s (+5.4% 🔺)1.340s121.00x
▲ VercelNext.js (Turbopack)7.287s (-28.4% 🟢)7.260s (-37.0% 🟢)0.000s (NaN%)9.165s (-23.9% 🟢)1.878s71.95x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

fan-out fan-in 10 streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.383s (-22.8% 🟢)2.141s (~)0.000s (+100.0% 🔺)2.153s (-1.0%)0.770s281.00x
🐘 PostgresExpress1.504s (-15.1% 🟢)2.097s (-3.7%)0.000s (NaN%)2.131s (-3.1%)0.627s291.09x
🐘 PostgresNext.js (Turbopack)1.667s2.224s0.000s2.233s0.566s271.21x
💻 LocalNext.js (Turbopack)2.804s3.361s0.000s3.365s0.561s182.03x
💻 LocalNitro3.108s (-8.2% 🟢)3.841s (-4.7%)0.000s (-18.0% 🟢)3.843s (-4.8%)0.735s162.25x
💻 LocalExpress3.249s (-6.3% 🟢)3.842s (-4.7%)0.001s (-21.9% 🟢)3.845s (-4.7%)0.596s162.35x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.969s (+45.8% 🔺)7.219s (+34.3% 🔺)0.000s (-100.0% 🟢)7.627s (+31.6% 🔺)1.658s81.00x
▲ VercelNext.js (Turbopack)9.307s (+65.7% 🔺)9.811s (+40.5% 🔺)0.001s (+300.0% 🔺)11.072s (+46.8% 🔺)1.765s61.56x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro15/21
🐘 PostgresNitro12/21
▲ VercelNitro18/21
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express🐘 Postgres19/21
Next.js (Turbopack)🐘 Postgres10/21
Nitro🐘 Postgres17/21
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)
  • Slurp: Time from first byte to complete stream consumption (stream benchmarks only)
  • Wall Time: Total testbench time (trigger workflow + poll for result)
  • Overhead: Testbench overhead (Wall Time - Workflow Time)
  • Samples: Number of benchmark iterations run
  • vs Fastest: How much slower compared to the fastest configuration for this benchmark

Worlds:

  • 💻 Local: In-memory filesystem world (local development)
  • 🐘 Postgres: PostgreSQL database world (local development)
  • ▲ Vercel: Vercel production/preview deployment
  • 🌐 Turso: Community world (local development)
  • 🌐 MongoDB: Community world (local development)
  • 🌐 Redis: Community world (local development)
  • 🌐 Jazz: Community world (local development)

📋 View full workflow run


Some benchmark jobs failed:

  • Local: success
  • Postgres: success
  • Vercel: failure

Check the workflow run for details.

@karthikscale3karthikscale3 left a comment

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.

LGTM. Verified it in the SWC playground.

CopilotAI left a comment

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.

Pull request overview

This PR adjusts the SWC workflow transform so dead-code elimination runs after nested step hoisting, with the goal of preserving module imports that hoisted step bodies still reference in step-mode output.

Changes:

  • Moves remove_dead_code from visit_mut_module_items to the end of visit_mut_program.
  • Updates existing step-mode fixtures whose hoisted steps now correctly retain required imports.
  • Adds a regression fixture covering nested steps that reference module-level imports.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
packages/swc-plugin-workflow/transform/tests/fixture/nested-steps-in-object-constructor/output-step.jsUpdates expected step output to retain an import used by a hoisted nested step.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-with-closure/output-step.jsUpdates expected step output to retain an import referenced from hoisted closure-based steps.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/output-workflow.jsAdds workflow-mode regression output for the new nested-import fixture.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/output-step.jsAdds step-mode regression output showing preserved imports for a hoisted nested step.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/input.jsAdds the new regression input covering nested step references to module imports.
packages/swc-plugin-workflow/transform/tests/fixture/factory-with-step-method/output-step.jsUpdates expected step output to retain an import used by a hoisted step method.
packages/swc-plugin-workflow/transform/src/lib.rsDefers dead-code elimination until after nested step hoisting completes.
.changeset/preserve-imports-used-by-hoisted-steps.mdRecords the patch release note for the SWC plugin fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/swc-plugin-workflow/transform/src/lib.rs
…nctions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.

CopilotAI left a comment

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.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/swc-plugin-workflow/transform/src/lib.rs
Comment thread.changeset/preserve-imports-used-by-hoisted-steps.md Outdated
…n shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
@TooTallNate
TooTallNate enabled auto-merge (squash) May 5, 2026 21:34
@TooTallNate
TooTallNate merged commit 1d4f83a into mainMay 5, 2026
113 of 114 checks passed
@TooTallNate
TooTallNate deleted the swc-plugin/preserve-imports-for-hoisted-steps branch May 5, 2026 21:36
github-actionsBot added a commit that referenced this pull request May 5, 2026
* [swc-plugin] Preserve imports referenced by hoisted nested steps
Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
* [swc-plugin] Namespace nested step IDs under non-exported workflow functions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.
* [swc-plugin] Namespace nested step IDs across all workflow declaration shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
Signed-off-by: Nathan Rajlich <n@n8.io>
@github-actions

Copy link
Copy Markdown
Contributor

Backport PR opened against stable: #1946. Merge conflicts were resolved by AI — please review carefully.

TooTallNate added a commit that referenced this pull request May 22, 2026
…) (#1946)
* [swc-plugin] Preserve imports referenced by hoisted nested steps
Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
* [swc-plugin] Namespace nested step IDs under non-exported workflow functions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.
* [swc-plugin] Namespace nested step IDs across all workflow declaration shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
Signed-off-by: Nathan Rajlich <n@n8.io>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Nathan Rajlich <n@n8.io>
@github-actionsgithub-actionsBot mentioned this pull request May 22, 2026
TooTallNate added a commit that referenced this pull request May 22, 2026
The fixture was introduced by the backport of #1935 (#1945) with the
pre-namespacing step ID "step//./input//step" in the __internal_workflows
manifest comment. The subsequent backport of #1944 (#1946) shipped the
namespacing fix in lib.rs but did not update this fixture, since on main
the two PRs landed in the reverse order and #1944's diff already covered
the fixture there.
Update the expected output to match what the plugin now emits:
"step//./input//outer/step" — same value already present in main.
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.

3 participants

@TooTallNate@karthikscale3
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

[swc-plugin] Preserve imports referenced by hoisted nested steps - #1944

Merged
TooTallNate merged 3 commits into
mainfrom
swc-plugin/preserve-imports-for-hoisted-steps
May 5, 2026
Merged

[swc-plugin] Preserve imports referenced by hoisted nested steps#1944
TooTallNate merged 3 commits into
mainfrom
swc-plugin/preserve-imports-for-hoisted-steps

Conversation

@TooTallNate

Copy link
Copy Markdown
Member

Summary

Fixes a bug in the SWC plugin where step-mode bundles dropped module-level imports that were referenced by step functions hoisted out of workflow bodies, causing a ReferenceError at runtime.

Root Cause

Ordering bug in the transform pipeline:

  1. StepTransform::visit_mut_module_items runs and, at the end, invokes remove_dead_code, which strips any import not referenced by current top-level code.
  2. StepTransform::visit_mut_program then hoists nested step functions out of workflow bodies onto the module top level (e.g. var _anonymousStep0 = async (input) => db.query(input.query);).
  3. The hoisted body references db, but the import was already deleted in step 1.

This only affected steps nested inside workflow function bodies — top-level steps already worked because their bodies were inlined in items before DCE ran. Three pre-existing fixtures (nested-step-with-closure, nested-steps-in-object-constructor, factory-with-step-method) had committed buggy outputs that this change corrects.

For example, given:

import{db}from'./db';asyncfunctionw(){'use workflow';constagent=newWorkflowAgent({tools: ()=>({queryDatabase: tool({execute: async(input)=>{'use step';returndb.query(input.query);},}),}),});}

The previous step-mode output omitted import { db } from './db'; while still emitting var _anonymousStep0 = async (input) => db.query(input.query);.

Fix

In packages/swc-plugin-workflow/transform/src/lib.rs:

  • Removed the early remove_dead_code call from the end of visit_mut_module_items.
  • Added a single remove_dead_code(&mut module.body) call in visit_mut_program, after nested step hoisting completes (right before metadata-comment insertion).

Verification

  • Added regression fixture tests/fixture/nested-step-references-module-import/ covering both kept-imports (used by hoisted step) and stripped-imports (truly unused, or only used by replaced workflow body).
  • All 124 SWC fixture tests pass.
  • Three pre-existing fixtures had their output-step.js files updated to now correctly include the imports their hoisted steps reference.
  • spec.md already documented the desired behavior — no spec change needed; this is purely an implementation conformance fix.

Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
CopilotAI review requested due to automatic review settings May 5, 2026 20:21
@vercel

vercelBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

@changeset-bot

changeset-botBot commented May 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9d132e5

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

This PR includes changesets to release 19 packages
NameType
@workflow/swc-pluginPatch
@workflow/astroPatch
@workflow/buildersPatch
@workflow/cliPatch
@workflow/nestPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
tarballsPatch
workflowPatch
@workflow/vitePatch
@workflow/vitestPatch
@workflow/world-testingPatch
@workflow/nuxtPatch
@workflow/aiPatch
@workflow/corePatch
@workflow/web-sharedPatch
@workflow/webPatch

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

@github-actions

github-actionsBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production120002191419
✅ 💻 Local Development158702191806
✅ 📦 Local Production158702191806
✅ 🐘 Local Postgres158702191806
✅ 🪟 Windows12900129
✅ 📋 Other7270176903
Total6817010527869

Details by Category

✅ ▲ Vercel Production
AppPassedFailedSkipped
✅ astro103026
✅ example103026
✅ express103026
✅ fastify103026
✅ hono103026
✅ nextjs-turbopack12702
✅ nextjs-webpack12702
✅ nitro103026
✅ nuxt103026
✅ sveltekit12207
✅ vite103026
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack12900
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable104025
✅ e2e-local-dev-tanstack-start-104025
✅ e2e-local-postgres-nest-stable104025
✅ e2e-local-postgres-tanstack-start-104025
✅ e2e-local-prod-nest-stable104025
✅ e2e-local-prod-tanstack-start-104025
✅ e2e-vercel-prod-tanstack-start103026

📋 View full workflow run

@github-actions

github-actionsBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

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

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.033s (-22.7% 🟢)1.005s (~)0.972s101.00x
💻 LocalExpress0.036s (-19.2% 🟢)1.006s (~)0.970s101.08x
🐘 PostgresExpress0.045s (-21.7% 🟢)1.011s (~)0.965s101.36x
💻 LocalNext.js (Turbopack)0.049s1.005s0.956s101.47x
🐘 PostgresNitro0.051s (-47.0% 🟢)1.011s (-3.1%)0.961s101.52x
🌐 RedisNext.js (Turbopack)0.052s1.005s0.953s101.56x
🐘 PostgresNext.js (Turbopack)0.057s1.011s0.954s101.71x
🌐 MongoDBNext.js (Turbopack)0.129s1.007s0.879s103.86x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro0.220s (-46.4% 🟢)2.151s (-14.3% 🟢)1.931s101.00x
▲ VercelNext.js (Turbopack)1.154s (+359.0% 🔺)2.852s (+22.3% 🔺)1.698s105.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Express1.075s (-4.5%)2.007s (~)0.931s101.00x
💻 LocalNitro1.075s (-5.0%)2.006s (~)0.931s101.00x
🐘 PostgresNitro1.083s (-5.0%)2.009s (~)0.926s101.01x
🐘 PostgresExpress1.084s (-5.4% 🟢)2.009s (~)0.925s101.01x
💻 LocalNext.js (Turbopack)1.110s2.006s0.896s101.03x
🌐 RedisNext.js (Turbopack)1.111s2.006s0.895s101.03x
🐘 PostgresNext.js (Turbopack)1.129s2.008s0.879s101.05x
🌐 MongoDBNext.js (Turbopack)1.169s2.009s0.840s101.09x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro1.608s (-58.7% 🟢)3.463s (-41.4% 🟢)1.855s101.00x
▲ VercelNext.js (Turbopack)3.023s (+48.6% 🔺)4.583s (+19.6% 🔺)1.560s101.88x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro10.404s (-4.9%)11.023s (~)0.618s31.00x
🐘 PostgresExpress10.408s (-5.1% 🟢)11.018s (~)0.611s31.00x
🐘 PostgresNitro10.419s (-4.2%)11.016s (~)0.597s31.00x
💻 LocalExpress10.424s (-4.6%)11.022s (~)0.598s31.00x
🐘 PostgresNext.js (Turbopack)10.657s11.016s0.359s31.02x
💻 LocalNext.js (Turbopack)10.669s11.021s0.353s31.03x
🌐 RedisNext.js (Turbopack)10.691s11.022s0.332s31.03x
🌐 MongoDBNext.js (Turbopack)10.894s11.352s0.458s31.05x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro13.342s (-43.8% 🟢)14.917s (-40.6% 🟢)1.575s31.00x
▲ VercelNext.js (Turbopack)13.784s (-20.4% 🟢)15.604s (-19.6% 🟢)1.821s21.03x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express13.447s (-7.8% 🟢)14.017s (-6.7% 🟢)0.570s51.00x
🐘 PostgresNitro13.451s (-7.8% 🟢)14.015s (-6.7% 🟢)0.565s51.00x
💻 LocalNitro13.507s (-10.3% 🟢)14.027s (-12.5% 🟢)0.520s51.00x
💻 LocalExpress13.523s (-9.7% 🟢)14.028s (-6.7% 🟢)0.505s51.01x
💻 LocalNext.js (Turbopack)14.061s14.828s0.767s51.05x
🌐 RedisNext.js (Turbopack)14.100s15.029s0.929s41.05x
🐘 PostgresNext.js (Turbopack)14.112s15.017s0.905s41.05x
🌐 MongoDBNext.js (Turbopack)14.354s15.026s0.672s41.07x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro21.643s (-66.4% 🟢)23.304s (-65.0% 🟢)1.660s31.00x
▲ VercelNext.js (Turbopack)23.990s (-54.4% 🟢)25.981s (-52.4% 🟢)1.991s31.11x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express11.854s (-15.4% 🟢)12.015s (-17.7% 🟢)0.161s81.00x
💻 LocalNitro11.930s (-28.9% 🟢)12.022s (-29.4% 🟢)0.092s81.01x
🐘 PostgresNitro11.936s (-14.5% 🟢)12.266s (-14.3% 🟢)0.330s81.01x
💻 LocalExpress12.068s (-27.3% 🟢)12.774s (-25.0% 🟢)0.706s81.02x
🌐 RedisNext.js (Turbopack)12.966s13.310s0.344s71.09x
💻 LocalNext.js (Turbopack)13.010s13.167s0.157s71.10x
🐘 PostgresNext.js (Turbopack)13.305s14.016s0.710s71.12x
🌐 MongoDBNext.js (Turbopack)13.338s14.023s0.684s71.13x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro32.625s (-92.3% 🟢)34.494s (-91.9% 🟢)1.869s31.00x
▲ VercelNext.js (Turbopack)35.758s (-90.9% 🟢)37.455s (-90.5% 🟢)1.697s31.10x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.146s (-10.1% 🟢)2.007s (~)0.861s151.00x
🐘 PostgresExpress1.149s (-8.8% 🟢)2.007s (~)0.857s151.00x
💻 LocalNitro1.186s (-27.3% 🟢)2.006s (-3.3%)0.820s151.04x
💻 LocalExpress1.195s (-19.7% 🟢)2.006s (~)0.811s151.04x
🐘 PostgresNext.js (Turbopack)1.235s2.007s0.772s151.08x
🌐 RedisNext.js (Turbopack)1.254s2.006s0.752s151.09x
💻 LocalNext.js (Turbopack)1.292s2.006s0.714s151.13x
🌐 MongoDBNext.js (Turbopack)2.028s2.735s0.707s111.77x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.906s (+3.1%)4.524s (+4.7%)1.618s71.00x
▲ VercelNext.js (Turbopack)4.911s (+44.6% 🔺)6.214s (+26.0% 🔺)1.303s51.69x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.219s (-48.4% 🟢)2.008s (-33.3% 🟢)0.789s151.00x
🐘 PostgresNitro1.230s (-47.7% 🟢)2.007s (-33.3% 🟢)0.777s151.01x
🐘 PostgresNext.js (Turbopack)1.355s2.007s0.652s151.11x
💻 LocalNitro1.777s (-43.5% 🟢)2.006s (-48.4% 🟢)0.228s151.46x
💻 LocalNext.js (Turbopack)1.824s2.006s0.183s151.50x
💻 LocalExpress1.879s (-36.4% 🟢)2.223s (-35.6% 🟢)0.344s141.54x
🌐 RedisNext.js (Turbopack)2.358s3.008s0.650s101.93x
🌐 MongoDBNext.js (Turbopack)3.576s4.009s0.433s82.93x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.582s (-11.6% 🟢)5.158s (-12.9% 🟢)1.577s71.00x
▲ VercelNext.js (Turbopack)5.608s (-21.0% 🟢)7.256s (-18.5% 🟢)1.648s51.57x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.367s (-60.8% 🟢)2.007s (-49.9% 🟢)0.640s151.00x
🐘 PostgresNitro1.376s (-60.5% 🟢)2.007s (-49.9% 🟢)0.632s151.01x
🐘 PostgresNext.js (Turbopack)1.639s2.074s0.435s151.20x
🌐 RedisNext.js (Turbopack)3.586s4.010s0.423s82.62x
💻 LocalNitro5.274s (-36.8% 🟢)5.846s (-35.2% 🟢)0.572s63.86x
💻 LocalExpress5.587s (-33.0% 🟢)6.213s (-31.2% 🟢)0.626s54.09x
💻 LocalNext.js (Turbopack)5.748s6.213s0.465s54.20x
🌐 MongoDBNext.js (Turbopack)6.301s7.013s0.712s54.61x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.978s (+69.6% 🔺)8.125s (+46.8% 🔺)2.147s41.00x
▲ VercelNext.js (Turbopack)7.377s (-17.3% 🟢)9.561s (-12.8% 🟢)2.184s41.23x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.150s (-8.5% 🟢)2.008s (~)0.858s151.00x
🐘 PostgresNitro1.169s (-7.0% 🟢)2.008s (~)0.839s151.02x
🐘 PostgresNext.js (Turbopack)1.218s2.008s0.790s151.06x
🌐 RedisNext.js (Turbopack)1.240s2.006s0.766s151.08x
💻 LocalNext.js (Turbopack)1.322s2.006s0.684s151.15x
💻 LocalNitro1.398s (-25.1% 🟢)2.006s (-14.3% 🟢)0.608s151.22x
💻 LocalExpress1.423s (-24.8% 🟢)2.006s (-15.1% 🟢)0.583s151.24x
🌐 MongoDBNext.js (Turbopack)2.029s2.675s0.645s121.76x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.689s (+9.3% 🔺)4.494s (+7.8% 🔺)1.805s71.00x
▲ VercelNext.js (Turbopack)3.798s (+29.5% 🔺)5.672s (+22.2% 🔺)1.874s61.41x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.229s (-47.5% 🟢)2.008s (-33.3% 🟢)0.779s151.00x
🐘 PostgresNitro1.247s (-46.7% 🟢)2.008s (-33.3% 🟢)0.760s151.02x
🐘 PostgresNext.js (Turbopack)1.386s2.008s0.622s151.13x
💻 LocalExpress2.079s (-33.6% 🟢)2.510s (-33.3% 🟢)0.430s121.69x
💻 LocalNext.js (Turbopack)2.117s2.735s0.617s111.72x
💻 LocalNitro2.169s (-29.2% 🟢)2.593s (-33.3% 🟢)0.424s121.77x
🌐 RedisNext.js (Turbopack)2.343s3.008s0.665s101.91x
🌐 MongoDBNext.js (Turbopack)3.579s4.009s0.430s82.91x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.315s (+2.5%)4.910s (-3.3%)1.595s71.00x
▲ VercelNext.js (Turbopack)5.136s (+63.4% 🔺)7.036s (+55.6% 🔺)1.901s51.55x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.377s (-60.4% 🟢)2.007s (-49.9% 🟢)0.630s151.00x
🐘 PostgresExpress1.386s (-60.4% 🟢)2.008s (-49.9% 🟢)0.622s151.01x
🐘 PostgresNext.js (Turbopack)1.637s2.007s0.370s151.19x
🌐 RedisNext.js (Turbopack)3.635s4.009s0.374s82.64x
💻 LocalNitro5.492s (-39.9% 🟢)6.214s (-38.0% 🟢)0.722s53.99x
💻 LocalNext.js (Turbopack)5.810s6.413s0.603s54.22x
💻 LocalExpress5.859s (-33.4% 🟢)6.616s (-28.7% 🟢)0.757s54.25x
🌐 MongoDBNext.js (Turbopack)6.297s7.013s0.716s54.57x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)6.088s (-9.9% 🟢)8.239s (-3.6%)2.151s41.00x
▲ VercelNitro6.546s (+28.5% 🔺)8.394s (+23.1% 🔺)1.849s41.08x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

workflow with 10 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.440s (-46.4% 🟢)1.006s (~)0.566s601.00x
🐘 PostgresExpress0.454s (-45.8% 🟢)1.006s (-1.7%)0.552s601.03x
💻 LocalExpress0.504s (-48.8% 🟢)1.005s (-6.6% 🟢)0.500s601.15x
💻 LocalNitro0.524s (-46.5% 🟢)1.022s (-6.6% 🟢)0.498s591.19x
🌐 RedisNext.js (Turbopack)0.617s1.004s0.388s601.40x
🐘 PostgresNext.js (Turbopack)0.665s1.006s0.341s601.51x
💻 LocalNext.js (Turbopack)0.726s1.004s0.278s601.65x
🌐 MongoDBNext.js (Turbopack)0.744s1.006s0.262s601.69x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.295s (-76.0% 🟢)7.121s (-70.4% 🟢)1.826s91.00x
▲ VercelNext.js (Turbopack)6.625s (-54.3% 🟢)8.457s (-47.4% 🟢)1.832s81.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.015s (-47.4% 🟢)1.532s (-27.1% 🟢)0.518s591.00x
🐘 PostgresExpress1.052s (-46.8% 🟢)1.632s (-27.7% 🟢)0.580s561.04x
💻 LocalNitro1.204s (-60.3% 🟢)2.006s (-46.6% 🟢)0.801s451.19x
💻 LocalExpress1.286s (-57.4% 🟢)2.006s (-44.0% 🟢)0.720s451.27x
🌐 RedisNext.js (Turbopack)1.476s2.006s0.529s451.46x
🐘 PostgresNext.js (Turbopack)1.585s2.007s0.423s451.56x
💻 LocalNext.js (Turbopack)1.764s2.006s0.241s451.74x
🌐 MongoDBNext.js (Turbopack)1.840s2.007s0.168s451.81x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro12.861s (-67.4% 🟢)14.586s (-64.7% 🟢)1.725s71.00x
▲ VercelNext.js (Turbopack)16.086s (-67.7% 🟢)18.350s (-64.5% 🟢)2.264s51.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 50 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro2.063s (-49.7% 🟢)2.549s (-44.6% 🟢)0.486s481.00x
🐘 PostgresExpress2.126s (-46.7% 🟢)2.719s (-37.8% 🟢)0.592s451.03x
💻 LocalNitro2.678s (-71.2% 🟢)3.008s (-70.0% 🟢)0.330s401.30x
💻 LocalExpress2.803s (-69.6% 🟢)3.033s (-69.7% 🟢)0.230s401.36x
🌐 RedisNext.js (Turbopack)2.963s3.135s0.173s391.44x
🐘 PostgresNext.js (Turbopack)3.131s4.008s0.877s301.52x
💻 LocalNext.js (Turbopack)3.767s4.007s0.240s301.83x
🌐 MongoDBNext.js (Turbopack)4.174s5.012s0.838s242.02x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro40.280s (-58.4% 🟢)42.530s (-56.8% 🟢)2.250s31.00x
▲ VercelNext.js (Turbopack)46.873s (-56.3% 🟢)48.931s (-55.1% 🟢)2.058s31.16x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 10 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.187s (-33.9% 🟢)1.006s (~)0.818s601.00x
🐘 PostgresExpress0.190s (-32.8% 🟢)1.006s (~)0.816s601.01x
🐘 PostgresNext.js (Turbopack)0.236s1.006s0.770s601.26x
🌐 RedisNext.js (Turbopack)0.242s1.004s0.762s601.30x
💻 LocalNitro0.469s (-22.5% 🟢)1.021s (~)0.553s592.50x
💻 LocalExpress0.483s (-13.8% 🟢)1.005s (~)0.522s602.58x
💻 LocalNext.js (Turbopack)0.554s1.005s0.451s602.96x
🌐 MongoDBNext.js (Turbopack)1.030s1.825s0.794s335.50x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.619s (+57.7% 🔺)4.178s (+24.7% 🔺)1.559s151.00x
▲ VercelNext.js (Turbopack)3.871s (+91.4% 🔺)5.504s (+45.1% 🔺)1.633s121.48x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.315s (-36.6% 🟢)1.006s (~)0.691s901.00x
🐘 PostgresExpress0.325s (-36.3% 🟢)1.007s (~)0.682s901.03x
🌐 RedisNext.js (Turbopack)0.410s1.004s0.594s901.30x
🐘 PostgresNext.js (Turbopack)0.458s1.006s0.548s901.45x
💻 LocalNitro2.270s (-10.6% 🟢)2.944s (-2.2%)0.675s317.21x
💻 LocalExpress2.282s (-9.2% 🟢)3.009s (~)0.727s307.25x
💻 LocalNext.js (Turbopack)2.466s3.042s0.576s307.84x
🌐 MongoDBNext.js (Turbopack)2.605s3.007s0.402s308.28x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)8.211s (+132.3% 🔺)9.775s (+88.2% 🔺)1.564s101.00x
▲ VercelNitro9.758s (+202.5% 🔺)11.351s (+135.4% 🔺)1.593s81.19x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

workflow with 50 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.652s (-17.5% 🟢)1.006s (~)0.354s1201.00x
🐘 PostgresExpress0.697s (-14.9% 🟢)1.007s (-1.0%)0.310s1201.07x
🌐 RedisNext.js (Turbopack)0.755s1.004s0.249s1201.16x
🐘 PostgresNext.js (Turbopack)0.944s1.340s0.397s901.45x
🌐 MongoDBNext.js (Turbopack)5.389s6.013s0.624s208.27x
💻 LocalNitro10.289s (-8.1% 🟢)10.781s (-7.6% 🟢)0.492s1215.78x
💻 LocalExpress11.054s (-1.2%)11.668s (-2.3%)0.615s1116.96x
💻 LocalNext.js (Turbopack)11.576s12.233s0.657s1017.76x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)19.155s (+85.5% 🔺)21.092s (+71.7% 🔺)1.938s61.00x
▲ VercelNitro23.620s (+205.8% 🔺)25.372s (+169.9% 🔺)1.753s51.23x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.133s (+452.2% 🔺)1.997s (+100.0% 🔺)0.001s (-18.8% 🟢)2.011s (+98.8% 🔺)0.878s101.00x
🐘 PostgresNitro1.140s (+456.1% 🔺)1.997s (+99.8% 🔺)0.001s (-13.3% 🟢)2.011s (+98.8% 🔺)0.871s101.01x
💻 LocalNitro1.141s (+434.1% 🔺)2.005s (+99.6% 🔺)0.013s (+1.6%)2.021s (+98.3% 🔺)0.879s101.01x
💻 LocalExpress1.142s (+473.8% 🔺)2.006s (+99.7% 🔺)0.013s (+4.1%)2.021s (+98.5% 🔺)0.878s101.01x
💻 LocalNext.js (Turbopack)1.176s2.004s0.012s2.020s0.844s101.04x
🐘 PostgresNext.js (Turbopack)1.196s2.001s0.002s2.011s0.816s101.06x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.149s (-43.9% 🟢)3.058s (-42.1% 🟢)1.931s (+160.2% 🔺)5.669s (-12.6% 🟢)3.520s101.00x
▲ VercelNext.js (Turbopack)4.815s (-29.7% 🟢)5.037s (-41.8% 🟢)0.879s (+39.1% 🔺)7.516s (-23.2% 🟢)2.701s102.24x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

stream pipeline with 5 transform steps (1MB)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.522s (+143.9% 🔺)1.999s (+98.6% 🔺)0.004s (-9.7% 🟢)2.025s (+98.1% 🔺)0.503s301.00x
🐘 PostgresExpress1.563s (+148.0% 🔺)2.005s (+99.2% 🔺)0.004s (-4.3%)2.025s (+98.0% 🔺)0.463s301.03x
💻 LocalNext.js (Turbopack)1.664s2.010s0.009s2.023s0.359s301.09x
🐘 PostgresNext.js (Turbopack)1.669s2.009s0.004s2.024s0.355s301.10x
💻 LocalNitro1.705s (+103.2% 🔺)2.011s (+98.7% 🔺)0.009s (-7.0% 🟢)2.201s (+97.2% 🔺)0.496s281.12x
💻 LocalExpress1.755s (+131.8% 🔺)2.012s (+95.6% 🔺)0.011s (+14.6% 🔺)2.204s (+112.0% 🔺)0.449s281.15x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.949s (-79.8% 🟢)7.135s (-76.8% 🟢)0.212s (+89.2% 🔺)7.803s (-75.4% 🟢)1.855s81.00x
▲ VercelNext.js (Turbopack)12.421s (-26.6% 🟢)12.915s (-29.2% 🟢)0.180s (-14.7% 🟢)14.203s (-25.0% 🟢)1.782s52.09x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

10 parallel streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.674s (-30.4% 🟢)1.050s (-15.9% 🟢)0.000s (-15.8% 🟢)1.064s (-15.4% 🟢)0.390s571.00x
🐘 PostgresExpress0.714s (-25.7% 🟢)1.031s (-19.3% 🟢)0.000s (-100.0% 🟢)1.043s (-20.1% 🟢)0.329s581.06x
🐘 PostgresNext.js (Turbopack)0.787s1.035s0.000s1.049s0.262s581.17x
💻 LocalNitro1.303s (+6.6% 🔺)2.015s (~)0.000s (+166.7% 🔺)2.017s (~)0.714s301.93x
💻 LocalExpress1.426s (+16.4% 🔺)2.015s (~)0.000s (-20.0% 🟢)2.018s (~)0.591s302.11x
💻 LocalNext.js (Turbopack)1.611s2.014s0.000s2.197s0.586s282.39x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.728s (+22.2% 🔺)4.649s (+5.8% 🔺)0.001s (+766.7% 🔺)5.068s (+5.4% 🔺)1.340s121.00x
▲ VercelNext.js (Turbopack)7.287s (-28.4% 🟢)7.260s (-37.0% 🟢)0.000s (NaN%)9.165s (-23.9% 🟢)1.878s71.95x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

fan-out fan-in 10 streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.383s (-22.8% 🟢)2.141s (~)0.000s (+100.0% 🔺)2.153s (-1.0%)0.770s281.00x
🐘 PostgresExpress1.504s (-15.1% 🟢)2.097s (-3.7%)0.000s (NaN%)2.131s (-3.1%)0.627s291.09x
🐘 PostgresNext.js (Turbopack)1.667s2.224s0.000s2.233s0.566s271.21x
💻 LocalNext.js (Turbopack)2.804s3.361s0.000s3.365s0.561s182.03x
💻 LocalNitro3.108s (-8.2% 🟢)3.841s (-4.7%)0.000s (-18.0% 🟢)3.843s (-4.8%)0.735s162.25x
💻 LocalExpress3.249s (-6.3% 🟢)3.842s (-4.7%)0.001s (-21.9% 🟢)3.845s (-4.7%)0.596s162.35x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.969s (+45.8% 🔺)7.219s (+34.3% 🔺)0.000s (-100.0% 🟢)7.627s (+31.6% 🔺)1.658s81.00x
▲ VercelNext.js (Turbopack)9.307s (+65.7% 🔺)9.811s (+40.5% 🔺)0.001s (+300.0% 🔺)11.072s (+46.8% 🔺)1.765s61.56x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro15/21
🐘 PostgresNitro12/21
▲ VercelNitro18/21
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express🐘 Postgres19/21
Next.js (Turbopack)🐘 Postgres10/21
Nitro🐘 Postgres17/21
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)
  • Slurp: Time from first byte to complete stream consumption (stream benchmarks only)
  • Wall Time: Total testbench time (trigger workflow + poll for result)
  • Overhead: Testbench overhead (Wall Time - Workflow Time)
  • Samples: Number of benchmark iterations run
  • vs Fastest: How much slower compared to the fastest configuration for this benchmark

Worlds:

  • 💻 Local: In-memory filesystem world (local development)
  • 🐘 Postgres: PostgreSQL database world (local development)
  • ▲ Vercel: Vercel production/preview deployment
  • 🌐 Turso: Community world (local development)
  • 🌐 MongoDB: Community world (local development)
  • 🌐 Redis: Community world (local development)
  • 🌐 Jazz: Community world (local development)

📋 View full workflow run


Some benchmark jobs failed:

  • Local: success
  • Postgres: success
  • Vercel: failure

Check the workflow run for details.

@karthikscale3karthikscale3 left a comment

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.

LGTM. Verified it in the SWC playground.

CopilotAI left a comment

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.

Pull request overview

This PR adjusts the SWC workflow transform so dead-code elimination runs after nested step hoisting, with the goal of preserving module imports that hoisted step bodies still reference in step-mode output.

Changes:

  • Moves remove_dead_code from visit_mut_module_items to the end of visit_mut_program.
  • Updates existing step-mode fixtures whose hoisted steps now correctly retain required imports.
  • Adds a regression fixture covering nested steps that reference module-level imports.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
packages/swc-plugin-workflow/transform/tests/fixture/nested-steps-in-object-constructor/output-step.jsUpdates expected step output to retain an import used by a hoisted nested step.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-with-closure/output-step.jsUpdates expected step output to retain an import referenced from hoisted closure-based steps.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/output-workflow.jsAdds workflow-mode regression output for the new nested-import fixture.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/output-step.jsAdds step-mode regression output showing preserved imports for a hoisted nested step.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/input.jsAdds the new regression input covering nested step references to module imports.
packages/swc-plugin-workflow/transform/tests/fixture/factory-with-step-method/output-step.jsUpdates expected step output to retain an import used by a hoisted step method.
packages/swc-plugin-workflow/transform/src/lib.rsDefers dead-code elimination until after nested step hoisting completes.
.changeset/preserve-imports-used-by-hoisted-steps.mdRecords the patch release note for the SWC plugin fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/swc-plugin-workflow/transform/src/lib.rs
…nctions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.

CopilotAI left a comment

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.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/swc-plugin-workflow/transform/src/lib.rs
Comment thread.changeset/preserve-imports-used-by-hoisted-steps.md Outdated
…n shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
@TooTallNate
TooTallNate enabled auto-merge (squash) May 5, 2026 21:34
@TooTallNate
TooTallNate merged commit 1d4f83a into mainMay 5, 2026
113 of 114 checks passed
@TooTallNate
TooTallNate deleted the swc-plugin/preserve-imports-for-hoisted-steps branch May 5, 2026 21:36
github-actionsBot added a commit that referenced this pull request May 5, 2026
* [swc-plugin] Preserve imports referenced by hoisted nested steps
Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
* [swc-plugin] Namespace nested step IDs under non-exported workflow functions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.
* [swc-plugin] Namespace nested step IDs across all workflow declaration shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
Signed-off-by: Nathan Rajlich <n@n8.io>
@github-actions

Copy link
Copy Markdown
Contributor

Backport PR opened against stable: #1946. Merge conflicts were resolved by AI — please review carefully.

TooTallNate added a commit that referenced this pull request May 22, 2026
…) (#1946)
* [swc-plugin] Preserve imports referenced by hoisted nested steps
Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
* [swc-plugin] Namespace nested step IDs under non-exported workflow functions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.
* [swc-plugin] Namespace nested step IDs across all workflow declaration shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
Signed-off-by: Nathan Rajlich <n@n8.io>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Nathan Rajlich <n@n8.io>
@github-actionsgithub-actionsBot mentioned this pull request May 22, 2026
TooTallNate added a commit that referenced this pull request May 22, 2026
The fixture was introduced by the backport of #1935 (#1945) with the
pre-namespacing step ID "step//./input//step" in the __internal_workflows
manifest comment. The subsequent backport of #1944 (#1946) shipped the
namespacing fix in lib.rs but did not update this fixture, since on main
the two PRs landed in the reverse order and #1944's diff already covered
the fixture there.
Update the expected output to match what the plugin now emits:
"step//./input//outer/step" — same value already present in main.
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.

3 participants

@TooTallNate@karthikscale3
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

[swc-plugin] Preserve imports referenced by hoisted nested steps - #1944

Merged
TooTallNate merged 3 commits into
mainfrom
swc-plugin/preserve-imports-for-hoisted-steps
May 5, 2026
Merged

[swc-plugin] Preserve imports referenced by hoisted nested steps#1944
TooTallNate merged 3 commits into
mainfrom
swc-plugin/preserve-imports-for-hoisted-steps

Conversation

@TooTallNate

Copy link
Copy Markdown
Member

Summary

Fixes a bug in the SWC plugin where step-mode bundles dropped module-level imports that were referenced by step functions hoisted out of workflow bodies, causing a ReferenceError at runtime.

Root Cause

Ordering bug in the transform pipeline:

  1. StepTransform::visit_mut_module_items runs and, at the end, invokes remove_dead_code, which strips any import not referenced by current top-level code.
  2. StepTransform::visit_mut_program then hoists nested step functions out of workflow bodies onto the module top level (e.g. var _anonymousStep0 = async (input) => db.query(input.query);).
  3. The hoisted body references db, but the import was already deleted in step 1.

This only affected steps nested inside workflow function bodies — top-level steps already worked because their bodies were inlined in items before DCE ran. Three pre-existing fixtures (nested-step-with-closure, nested-steps-in-object-constructor, factory-with-step-method) had committed buggy outputs that this change corrects.

For example, given:

import{db}from'./db';asyncfunctionw(){'use workflow';constagent=newWorkflowAgent({tools: ()=>({queryDatabase: tool({execute: async(input)=>{'use step';returndb.query(input.query);},}),}),});}

The previous step-mode output omitted import { db } from './db'; while still emitting var _anonymousStep0 = async (input) => db.query(input.query);.

Fix

In packages/swc-plugin-workflow/transform/src/lib.rs:

  • Removed the early remove_dead_code call from the end of visit_mut_module_items.
  • Added a single remove_dead_code(&mut module.body) call in visit_mut_program, after nested step hoisting completes (right before metadata-comment insertion).

Verification

  • Added regression fixture tests/fixture/nested-step-references-module-import/ covering both kept-imports (used by hoisted step) and stripped-imports (truly unused, or only used by replaced workflow body).
  • All 124 SWC fixture tests pass.
  • Three pre-existing fixtures had their output-step.js files updated to now correctly include the imports their hoisted steps reference.
  • spec.md already documented the desired behavior — no spec change needed; this is purely an implementation conformance fix.

Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
CopilotAI review requested due to automatic review settings May 5, 2026 20:21
@vercel

vercelBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

@changeset-bot

changeset-botBot commented May 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9d132e5

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

This PR includes changesets to release 19 packages
NameType
@workflow/swc-pluginPatch
@workflow/astroPatch
@workflow/buildersPatch
@workflow/cliPatch
@workflow/nestPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
tarballsPatch
workflowPatch
@workflow/vitePatch
@workflow/vitestPatch
@workflow/world-testingPatch
@workflow/nuxtPatch
@workflow/aiPatch
@workflow/corePatch
@workflow/web-sharedPatch
@workflow/webPatch

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

@github-actions

github-actionsBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production120002191419
✅ 💻 Local Development158702191806
✅ 📦 Local Production158702191806
✅ 🐘 Local Postgres158702191806
✅ 🪟 Windows12900129
✅ 📋 Other7270176903
Total6817010527869

Details by Category

✅ ▲ Vercel Production
AppPassedFailedSkipped
✅ astro103026
✅ example103026
✅ express103026
✅ fastify103026
✅ hono103026
✅ nextjs-turbopack12702
✅ nextjs-webpack12702
✅ nitro103026
✅ nuxt103026
✅ sveltekit12207
✅ vite103026
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable104025
✅ express-stable104025
✅ fastify-stable104025
✅ hono-stable104025
✅ nextjs-turbopack-canary110019
✅ nextjs-turbopack-stable-lazy-discovery-disabled12900
✅ nextjs-turbopack-stable-lazy-discovery-enabled12900
✅ nextjs-webpack-canary110019
✅ nextjs-webpack-stable-lazy-discovery-disabled12900
✅ nextjs-webpack-stable-lazy-discovery-enabled12900
✅ nitro-stable104025
✅ nuxt-stable104025
✅ sveltekit-stable12306
✅ vite-stable104025
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack12900
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable104025
✅ e2e-local-dev-tanstack-start-104025
✅ e2e-local-postgres-nest-stable104025
✅ e2e-local-postgres-tanstack-start-104025
✅ e2e-local-prod-nest-stable104025
✅ e2e-local-prod-tanstack-start-104025
✅ e2e-vercel-prod-tanstack-start103026

📋 View full workflow run

@github-actions

github-actionsBot commented May 5, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

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

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.033s (-22.7% 🟢)1.005s (~)0.972s101.00x
💻 LocalExpress0.036s (-19.2% 🟢)1.006s (~)0.970s101.08x
🐘 PostgresExpress0.045s (-21.7% 🟢)1.011s (~)0.965s101.36x
💻 LocalNext.js (Turbopack)0.049s1.005s0.956s101.47x
🐘 PostgresNitro0.051s (-47.0% 🟢)1.011s (-3.1%)0.961s101.52x
🌐 RedisNext.js (Turbopack)0.052s1.005s0.953s101.56x
🐘 PostgresNext.js (Turbopack)0.057s1.011s0.954s101.71x
🌐 MongoDBNext.js (Turbopack)0.129s1.007s0.879s103.86x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro0.220s (-46.4% 🟢)2.151s (-14.3% 🟢)1.931s101.00x
▲ VercelNext.js (Turbopack)1.154s (+359.0% 🔺)2.852s (+22.3% 🔺)1.698s105.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Express1.075s (-4.5%)2.007s (~)0.931s101.00x
💻 LocalNitro1.075s (-5.0%)2.006s (~)0.931s101.00x
🐘 PostgresNitro1.083s (-5.0%)2.009s (~)0.926s101.01x
🐘 PostgresExpress1.084s (-5.4% 🟢)2.009s (~)0.925s101.01x
💻 LocalNext.js (Turbopack)1.110s2.006s0.896s101.03x
🌐 RedisNext.js (Turbopack)1.111s2.006s0.895s101.03x
🐘 PostgresNext.js (Turbopack)1.129s2.008s0.879s101.05x
🌐 MongoDBNext.js (Turbopack)1.169s2.009s0.840s101.09x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro1.608s (-58.7% 🟢)3.463s (-41.4% 🟢)1.855s101.00x
▲ VercelNext.js (Turbopack)3.023s (+48.6% 🔺)4.583s (+19.6% 🔺)1.560s101.88x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro10.404s (-4.9%)11.023s (~)0.618s31.00x
🐘 PostgresExpress10.408s (-5.1% 🟢)11.018s (~)0.611s31.00x
🐘 PostgresNitro10.419s (-4.2%)11.016s (~)0.597s31.00x
💻 LocalExpress10.424s (-4.6%)11.022s (~)0.598s31.00x
🐘 PostgresNext.js (Turbopack)10.657s11.016s0.359s31.02x
💻 LocalNext.js (Turbopack)10.669s11.021s0.353s31.03x
🌐 RedisNext.js (Turbopack)10.691s11.022s0.332s31.03x
🌐 MongoDBNext.js (Turbopack)10.894s11.352s0.458s31.05x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro13.342s (-43.8% 🟢)14.917s (-40.6% 🟢)1.575s31.00x
▲ VercelNext.js (Turbopack)13.784s (-20.4% 🟢)15.604s (-19.6% 🟢)1.821s21.03x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express13.447s (-7.8% 🟢)14.017s (-6.7% 🟢)0.570s51.00x
🐘 PostgresNitro13.451s (-7.8% 🟢)14.015s (-6.7% 🟢)0.565s51.00x
💻 LocalNitro13.507s (-10.3% 🟢)14.027s (-12.5% 🟢)0.520s51.00x
💻 LocalExpress13.523s (-9.7% 🟢)14.028s (-6.7% 🟢)0.505s51.01x
💻 LocalNext.js (Turbopack)14.061s14.828s0.767s51.05x
🌐 RedisNext.js (Turbopack)14.100s15.029s0.929s41.05x
🐘 PostgresNext.js (Turbopack)14.112s15.017s0.905s41.05x
🌐 MongoDBNext.js (Turbopack)14.354s15.026s0.672s41.07x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro21.643s (-66.4% 🟢)23.304s (-65.0% 🟢)1.660s31.00x
▲ VercelNext.js (Turbopack)23.990s (-54.4% 🟢)25.981s (-52.4% 🟢)1.991s31.11x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express11.854s (-15.4% 🟢)12.015s (-17.7% 🟢)0.161s81.00x
💻 LocalNitro11.930s (-28.9% 🟢)12.022s (-29.4% 🟢)0.092s81.01x
🐘 PostgresNitro11.936s (-14.5% 🟢)12.266s (-14.3% 🟢)0.330s81.01x
💻 LocalExpress12.068s (-27.3% 🟢)12.774s (-25.0% 🟢)0.706s81.02x
🌐 RedisNext.js (Turbopack)12.966s13.310s0.344s71.09x
💻 LocalNext.js (Turbopack)13.010s13.167s0.157s71.10x
🐘 PostgresNext.js (Turbopack)13.305s14.016s0.710s71.12x
🌐 MongoDBNext.js (Turbopack)13.338s14.023s0.684s71.13x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro32.625s (-92.3% 🟢)34.494s (-91.9% 🟢)1.869s31.00x
▲ VercelNext.js (Turbopack)35.758s (-90.9% 🟢)37.455s (-90.5% 🟢)1.697s31.10x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.146s (-10.1% 🟢)2.007s (~)0.861s151.00x
🐘 PostgresExpress1.149s (-8.8% 🟢)2.007s (~)0.857s151.00x
💻 LocalNitro1.186s (-27.3% 🟢)2.006s (-3.3%)0.820s151.04x
💻 LocalExpress1.195s (-19.7% 🟢)2.006s (~)0.811s151.04x
🐘 PostgresNext.js (Turbopack)1.235s2.007s0.772s151.08x
🌐 RedisNext.js (Turbopack)1.254s2.006s0.752s151.09x
💻 LocalNext.js (Turbopack)1.292s2.006s0.714s151.13x
🌐 MongoDBNext.js (Turbopack)2.028s2.735s0.707s111.77x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.906s (+3.1%)4.524s (+4.7%)1.618s71.00x
▲ VercelNext.js (Turbopack)4.911s (+44.6% 🔺)6.214s (+26.0% 🔺)1.303s51.69x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.219s (-48.4% 🟢)2.008s (-33.3% 🟢)0.789s151.00x
🐘 PostgresNitro1.230s (-47.7% 🟢)2.007s (-33.3% 🟢)0.777s151.01x
🐘 PostgresNext.js (Turbopack)1.355s2.007s0.652s151.11x
💻 LocalNitro1.777s (-43.5% 🟢)2.006s (-48.4% 🟢)0.228s151.46x
💻 LocalNext.js (Turbopack)1.824s2.006s0.183s151.50x
💻 LocalExpress1.879s (-36.4% 🟢)2.223s (-35.6% 🟢)0.344s141.54x
🌐 RedisNext.js (Turbopack)2.358s3.008s0.650s101.93x
🌐 MongoDBNext.js (Turbopack)3.576s4.009s0.433s82.93x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.582s (-11.6% 🟢)5.158s (-12.9% 🟢)1.577s71.00x
▲ VercelNext.js (Turbopack)5.608s (-21.0% 🟢)7.256s (-18.5% 🟢)1.648s51.57x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.367s (-60.8% 🟢)2.007s (-49.9% 🟢)0.640s151.00x
🐘 PostgresNitro1.376s (-60.5% 🟢)2.007s (-49.9% 🟢)0.632s151.01x
🐘 PostgresNext.js (Turbopack)1.639s2.074s0.435s151.20x
🌐 RedisNext.js (Turbopack)3.586s4.010s0.423s82.62x
💻 LocalNitro5.274s (-36.8% 🟢)5.846s (-35.2% 🟢)0.572s63.86x
💻 LocalExpress5.587s (-33.0% 🟢)6.213s (-31.2% 🟢)0.626s54.09x
💻 LocalNext.js (Turbopack)5.748s6.213s0.465s54.20x
🌐 MongoDBNext.js (Turbopack)6.301s7.013s0.712s54.61x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.978s (+69.6% 🔺)8.125s (+46.8% 🔺)2.147s41.00x
▲ VercelNext.js (Turbopack)7.377s (-17.3% 🟢)9.561s (-12.8% 🟢)2.184s41.23x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.150s (-8.5% 🟢)2.008s (~)0.858s151.00x
🐘 PostgresNitro1.169s (-7.0% 🟢)2.008s (~)0.839s151.02x
🐘 PostgresNext.js (Turbopack)1.218s2.008s0.790s151.06x
🌐 RedisNext.js (Turbopack)1.240s2.006s0.766s151.08x
💻 LocalNext.js (Turbopack)1.322s2.006s0.684s151.15x
💻 LocalNitro1.398s (-25.1% 🟢)2.006s (-14.3% 🟢)0.608s151.22x
💻 LocalExpress1.423s (-24.8% 🟢)2.006s (-15.1% 🟢)0.583s151.24x
🌐 MongoDBNext.js (Turbopack)2.029s2.675s0.645s121.76x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.689s (+9.3% 🔺)4.494s (+7.8% 🔺)1.805s71.00x
▲ VercelNext.js (Turbopack)3.798s (+29.5% 🔺)5.672s (+22.2% 🔺)1.874s61.41x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.229s (-47.5% 🟢)2.008s (-33.3% 🟢)0.779s151.00x
🐘 PostgresNitro1.247s (-46.7% 🟢)2.008s (-33.3% 🟢)0.760s151.02x
🐘 PostgresNext.js (Turbopack)1.386s2.008s0.622s151.13x
💻 LocalExpress2.079s (-33.6% 🟢)2.510s (-33.3% 🟢)0.430s121.69x
💻 LocalNext.js (Turbopack)2.117s2.735s0.617s111.72x
💻 LocalNitro2.169s (-29.2% 🟢)2.593s (-33.3% 🟢)0.424s121.77x
🌐 RedisNext.js (Turbopack)2.343s3.008s0.665s101.91x
🌐 MongoDBNext.js (Turbopack)3.579s4.009s0.430s82.91x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.315s (+2.5%)4.910s (-3.3%)1.595s71.00x
▲ VercelNext.js (Turbopack)5.136s (+63.4% 🔺)7.036s (+55.6% 🔺)1.901s51.55x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.377s (-60.4% 🟢)2.007s (-49.9% 🟢)0.630s151.00x
🐘 PostgresExpress1.386s (-60.4% 🟢)2.008s (-49.9% 🟢)0.622s151.01x
🐘 PostgresNext.js (Turbopack)1.637s2.007s0.370s151.19x
🌐 RedisNext.js (Turbopack)3.635s4.009s0.374s82.64x
💻 LocalNitro5.492s (-39.9% 🟢)6.214s (-38.0% 🟢)0.722s53.99x
💻 LocalNext.js (Turbopack)5.810s6.413s0.603s54.22x
💻 LocalExpress5.859s (-33.4% 🟢)6.616s (-28.7% 🟢)0.757s54.25x
🌐 MongoDBNext.js (Turbopack)6.297s7.013s0.716s54.57x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)6.088s (-9.9% 🟢)8.239s (-3.6%)2.151s41.00x
▲ VercelNitro6.546s (+28.5% 🔺)8.394s (+23.1% 🔺)1.849s41.08x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

workflow with 10 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.440s (-46.4% 🟢)1.006s (~)0.566s601.00x
🐘 PostgresExpress0.454s (-45.8% 🟢)1.006s (-1.7%)0.552s601.03x
💻 LocalExpress0.504s (-48.8% 🟢)1.005s (-6.6% 🟢)0.500s601.15x
💻 LocalNitro0.524s (-46.5% 🟢)1.022s (-6.6% 🟢)0.498s591.19x
🌐 RedisNext.js (Turbopack)0.617s1.004s0.388s601.40x
🐘 PostgresNext.js (Turbopack)0.665s1.006s0.341s601.51x
💻 LocalNext.js (Turbopack)0.726s1.004s0.278s601.65x
🌐 MongoDBNext.js (Turbopack)0.744s1.006s0.262s601.69x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.295s (-76.0% 🟢)7.121s (-70.4% 🟢)1.826s91.00x
▲ VercelNext.js (Turbopack)6.625s (-54.3% 🟢)8.457s (-47.4% 🟢)1.832s81.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.015s (-47.4% 🟢)1.532s (-27.1% 🟢)0.518s591.00x
🐘 PostgresExpress1.052s (-46.8% 🟢)1.632s (-27.7% 🟢)0.580s561.04x
💻 LocalNitro1.204s (-60.3% 🟢)2.006s (-46.6% 🟢)0.801s451.19x
💻 LocalExpress1.286s (-57.4% 🟢)2.006s (-44.0% 🟢)0.720s451.27x
🌐 RedisNext.js (Turbopack)1.476s2.006s0.529s451.46x
🐘 PostgresNext.js (Turbopack)1.585s2.007s0.423s451.56x
💻 LocalNext.js (Turbopack)1.764s2.006s0.241s451.74x
🌐 MongoDBNext.js (Turbopack)1.840s2.007s0.168s451.81x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro12.861s (-67.4% 🟢)14.586s (-64.7% 🟢)1.725s71.00x
▲ VercelNext.js (Turbopack)16.086s (-67.7% 🟢)18.350s (-64.5% 🟢)2.264s51.25x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 50 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro2.063s (-49.7% 🟢)2.549s (-44.6% 🟢)0.486s481.00x
🐘 PostgresExpress2.126s (-46.7% 🟢)2.719s (-37.8% 🟢)0.592s451.03x
💻 LocalNitro2.678s (-71.2% 🟢)3.008s (-70.0% 🟢)0.330s401.30x
💻 LocalExpress2.803s (-69.6% 🟢)3.033s (-69.7% 🟢)0.230s401.36x
🌐 RedisNext.js (Turbopack)2.963s3.135s0.173s391.44x
🐘 PostgresNext.js (Turbopack)3.131s4.008s0.877s301.52x
💻 LocalNext.js (Turbopack)3.767s4.007s0.240s301.83x
🌐 MongoDBNext.js (Turbopack)4.174s5.012s0.838s242.02x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro40.280s (-58.4% 🟢)42.530s (-56.8% 🟢)2.250s31.00x
▲ VercelNext.js (Turbopack)46.873s (-56.3% 🟢)48.931s (-55.1% 🟢)2.058s31.16x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 10 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.187s (-33.9% 🟢)1.006s (~)0.818s601.00x
🐘 PostgresExpress0.190s (-32.8% 🟢)1.006s (~)0.816s601.01x
🐘 PostgresNext.js (Turbopack)0.236s1.006s0.770s601.26x
🌐 RedisNext.js (Turbopack)0.242s1.004s0.762s601.30x
💻 LocalNitro0.469s (-22.5% 🟢)1.021s (~)0.553s592.50x
💻 LocalExpress0.483s (-13.8% 🟢)1.005s (~)0.522s602.58x
💻 LocalNext.js (Turbopack)0.554s1.005s0.451s602.96x
🌐 MongoDBNext.js (Turbopack)1.030s1.825s0.794s335.50x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.619s (+57.7% 🔺)4.178s (+24.7% 🔺)1.559s151.00x
▲ VercelNext.js (Turbopack)3.871s (+91.4% 🔺)5.504s (+45.1% 🔺)1.633s121.48x
▲ VercelExpress⚠️missing----

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.315s (-36.6% 🟢)1.006s (~)0.691s901.00x
🐘 PostgresExpress0.325s (-36.3% 🟢)1.007s (~)0.682s901.03x
🌐 RedisNext.js (Turbopack)0.410s1.004s0.594s901.30x
🐘 PostgresNext.js (Turbopack)0.458s1.006s0.548s901.45x
💻 LocalNitro2.270s (-10.6% 🟢)2.944s (-2.2%)0.675s317.21x
💻 LocalExpress2.282s (-9.2% 🟢)3.009s (~)0.727s307.25x
💻 LocalNext.js (Turbopack)2.466s3.042s0.576s307.84x
🌐 MongoDBNext.js (Turbopack)2.605s3.007s0.402s308.28x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)8.211s (+132.3% 🔺)9.775s (+88.2% 🔺)1.564s101.00x
▲ VercelNitro9.758s (+202.5% 🔺)11.351s (+135.4% 🔺)1.593s81.19x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

workflow with 50 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.652s (-17.5% 🟢)1.006s (~)0.354s1201.00x
🐘 PostgresExpress0.697s (-14.9% 🟢)1.007s (-1.0%)0.310s1201.07x
🌐 RedisNext.js (Turbopack)0.755s1.004s0.249s1201.16x
🐘 PostgresNext.js (Turbopack)0.944s1.340s0.397s901.45x
🌐 MongoDBNext.js (Turbopack)5.389s6.013s0.624s208.27x
💻 LocalNitro10.289s (-8.1% 🟢)10.781s (-7.6% 🟢)0.492s1215.78x
💻 LocalExpress11.054s (-1.2%)11.668s (-2.3%)0.615s1116.96x
💻 LocalNext.js (Turbopack)11.576s12.233s0.657s1017.76x

▲ Production (Vercel)

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Next.js (Turbopack)19.155s (+85.5% 🔺)21.092s (+71.7% 🔺)1.938s61.00x
▲ VercelNitro23.620s (+205.8% 🔺)25.372s (+169.9% 🔺)1.753s51.23x
▲ VercelExpress⚠️missing----

🔍 Observability: Next.js (Turbopack) | Nitro

Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.133s (+452.2% 🔺)1.997s (+100.0% 🔺)0.001s (-18.8% 🟢)2.011s (+98.8% 🔺)0.878s101.00x
🐘 PostgresNitro1.140s (+456.1% 🔺)1.997s (+99.8% 🔺)0.001s (-13.3% 🟢)2.011s (+98.8% 🔺)0.871s101.01x
💻 LocalNitro1.141s (+434.1% 🔺)2.005s (+99.6% 🔺)0.013s (+1.6%)2.021s (+98.3% 🔺)0.879s101.01x
💻 LocalExpress1.142s (+473.8% 🔺)2.006s (+99.7% 🔺)0.013s (+4.1%)2.021s (+98.5% 🔺)0.878s101.01x
💻 LocalNext.js (Turbopack)1.176s2.004s0.012s2.020s0.844s101.04x
🐘 PostgresNext.js (Turbopack)1.196s2.001s0.002s2.011s0.816s101.06x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro2.149s (-43.9% 🟢)3.058s (-42.1% 🟢)1.931s (+160.2% 🔺)5.669s (-12.6% 🟢)3.520s101.00x
▲ VercelNext.js (Turbopack)4.815s (-29.7% 🟢)5.037s (-41.8% 🟢)0.879s (+39.1% 🔺)7.516s (-23.2% 🟢)2.701s102.24x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

stream pipeline with 5 transform steps (1MB)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.522s (+143.9% 🔺)1.999s (+98.6% 🔺)0.004s (-9.7% 🟢)2.025s (+98.1% 🔺)0.503s301.00x
🐘 PostgresExpress1.563s (+148.0% 🔺)2.005s (+99.2% 🔺)0.004s (-4.3%)2.025s (+98.0% 🔺)0.463s301.03x
💻 LocalNext.js (Turbopack)1.664s2.010s0.009s2.023s0.359s301.09x
🐘 PostgresNext.js (Turbopack)1.669s2.009s0.004s2.024s0.355s301.10x
💻 LocalNitro1.705s (+103.2% 🔺)2.011s (+98.7% 🔺)0.009s (-7.0% 🟢)2.201s (+97.2% 🔺)0.496s281.12x
💻 LocalExpress1.755s (+131.8% 🔺)2.012s (+95.6% 🔺)0.011s (+14.6% 🔺)2.204s (+112.0% 🔺)0.449s281.15x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.949s (-79.8% 🟢)7.135s (-76.8% 🟢)0.212s (+89.2% 🔺)7.803s (-75.4% 🟢)1.855s81.00x
▲ VercelNext.js (Turbopack)12.421s (-26.6% 🟢)12.915s (-29.2% 🟢)0.180s (-14.7% 🟢)14.203s (-25.0% 🟢)1.782s52.09x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

10 parallel streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro0.674s (-30.4% 🟢)1.050s (-15.9% 🟢)0.000s (-15.8% 🟢)1.064s (-15.4% 🟢)0.390s571.00x
🐘 PostgresExpress0.714s (-25.7% 🟢)1.031s (-19.3% 🟢)0.000s (-100.0% 🟢)1.043s (-20.1% 🟢)0.329s581.06x
🐘 PostgresNext.js (Turbopack)0.787s1.035s0.000s1.049s0.262s581.17x
💻 LocalNitro1.303s (+6.6% 🔺)2.015s (~)0.000s (+166.7% 🔺)2.017s (~)0.714s301.93x
💻 LocalExpress1.426s (+16.4% 🔺)2.015s (~)0.000s (-20.0% 🟢)2.018s (~)0.591s302.11x
💻 LocalNext.js (Turbopack)1.611s2.014s0.000s2.197s0.586s282.39x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro3.728s (+22.2% 🔺)4.649s (+5.8% 🔺)0.001s (+766.7% 🔺)5.068s (+5.4% 🔺)1.340s121.00x
▲ VercelNext.js (Turbopack)7.287s (-28.4% 🟢)7.260s (-37.0% 🟢)0.000s (NaN%)9.165s (-23.9% 🟢)1.878s71.95x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

fan-out fan-in 10 streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Nitro1.383s (-22.8% 🟢)2.141s (~)0.000s (+100.0% 🔺)2.153s (-1.0%)0.770s281.00x
🐘 PostgresExpress1.504s (-15.1% 🟢)2.097s (-3.7%)0.000s (NaN%)2.131s (-3.1%)0.627s291.09x
🐘 PostgresNext.js (Turbopack)1.667s2.224s0.000s2.233s0.566s271.21x
💻 LocalNext.js (Turbopack)2.804s3.361s0.000s3.365s0.561s182.03x
💻 LocalNitro3.108s (-8.2% 🟢)3.841s (-4.7%)0.000s (-18.0% 🟢)3.843s (-4.8%)0.735s162.25x
💻 LocalExpress3.249s (-6.3% 🟢)3.842s (-4.7%)0.001s (-21.9% 🟢)3.845s (-4.7%)0.596s162.35x
🌐 MongoDBNext.js (Turbopack)⚠️missing-----
🌐 RedisNext.js (Turbopack)⚠️missing-----

▲ Production (Vercel)

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
▲ Vercel🥇 Nitro5.969s (+45.8% 🔺)7.219s (+34.3% 🔺)0.000s (-100.0% 🟢)7.627s (+31.6% 🔺)1.658s81.00x
▲ VercelNext.js (Turbopack)9.307s (+65.7% 🔺)9.811s (+40.5% 🔺)0.001s (+300.0% 🔺)11.072s (+46.8% 🔺)1.765s61.56x
▲ VercelExpress⚠️missing-----

🔍 Observability: Nitro | Next.js (Turbopack)

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro15/21
🐘 PostgresNitro12/21
▲ VercelNitro18/21
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express🐘 Postgres19/21
Next.js (Turbopack)🐘 Postgres10/21
Nitro🐘 Postgres17/21
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)
  • Slurp: Time from first byte to complete stream consumption (stream benchmarks only)
  • Wall Time: Total testbench time (trigger workflow + poll for result)
  • Overhead: Testbench overhead (Wall Time - Workflow Time)
  • Samples: Number of benchmark iterations run
  • vs Fastest: How much slower compared to the fastest configuration for this benchmark

Worlds:

  • 💻 Local: In-memory filesystem world (local development)
  • 🐘 Postgres: PostgreSQL database world (local development)
  • ▲ Vercel: Vercel production/preview deployment
  • 🌐 Turso: Community world (local development)
  • 🌐 MongoDB: Community world (local development)
  • 🌐 Redis: Community world (local development)
  • 🌐 Jazz: Community world (local development)

📋 View full workflow run


Some benchmark jobs failed:

  • Local: success
  • Postgres: success
  • Vercel: failure

Check the workflow run for details.

@karthikscale3karthikscale3 left a comment

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.

LGTM. Verified it in the SWC playground.

CopilotAI left a comment

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.

Pull request overview

This PR adjusts the SWC workflow transform so dead-code elimination runs after nested step hoisting, with the goal of preserving module imports that hoisted step bodies still reference in step-mode output.

Changes:

  • Moves remove_dead_code from visit_mut_module_items to the end of visit_mut_program.
  • Updates existing step-mode fixtures whose hoisted steps now correctly retain required imports.
  • Adds a regression fixture covering nested steps that reference module-level imports.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
packages/swc-plugin-workflow/transform/tests/fixture/nested-steps-in-object-constructor/output-step.jsUpdates expected step output to retain an import used by a hoisted nested step.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-with-closure/output-step.jsUpdates expected step output to retain an import referenced from hoisted closure-based steps.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/output-workflow.jsAdds workflow-mode regression output for the new nested-import fixture.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/output-step.jsAdds step-mode regression output showing preserved imports for a hoisted nested step.
packages/swc-plugin-workflow/transform/tests/fixture/nested-step-references-module-import/input.jsAdds the new regression input covering nested step references to module imports.
packages/swc-plugin-workflow/transform/tests/fixture/factory-with-step-method/output-step.jsUpdates expected step output to retain an import used by a hoisted step method.
packages/swc-plugin-workflow/transform/src/lib.rsDefers dead-code elimination until after nested step hoisting completes.
.changeset/preserve-imports-used-by-hoisted-steps.mdRecords the patch release note for the SWC plugin fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/swc-plugin-workflow/transform/src/lib.rs
…nctions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.

CopilotAI left a comment

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.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/swc-plugin-workflow/transform/src/lib.rs
Comment thread.changeset/preserve-imports-used-by-hoisted-steps.md Outdated
…n shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
@TooTallNate
TooTallNate enabled auto-merge (squash) May 5, 2026 21:34
@TooTallNate
TooTallNate merged commit 1d4f83a into mainMay 5, 2026
113 of 114 checks passed
@TooTallNate
TooTallNate deleted the swc-plugin/preserve-imports-for-hoisted-steps branch May 5, 2026 21:36
github-actionsBot added a commit that referenced this pull request May 5, 2026
* [swc-plugin] Preserve imports referenced by hoisted nested steps
Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
* [swc-plugin] Namespace nested step IDs under non-exported workflow functions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.
* [swc-plugin] Namespace nested step IDs across all workflow declaration shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
Signed-off-by: Nathan Rajlich <n@n8.io>
@github-actions

Copy link
Copy Markdown
Contributor

Backport PR opened against stable: #1946. Merge conflicts were resolved by AI — please review carefully.

TooTallNate added a commit that referenced this pull request May 22, 2026
…) (#1946)
* [swc-plugin] Preserve imports referenced by hoisted nested steps
Dead-code elimination ran before nested step functions were hoisted out of workflow bodies, so imports referenced only by hoisted step bodies were incorrectly stripped from the step bundle, causing a ReferenceError at runtime. Move DCE to run after hoisting in visit_mut_program.
* [swc-plugin] Namespace nested step IDs under non-exported workflow functions
Anonymous steps nested inside callback properties of a non-exported workflow function were registered with an unnamespaced step ID in step mode while the workflow-mode proxy looked them up under the workflow function name, causing a runtime 'step not found' failure. Set current_workflow_function_name in visit_mut_fn_decl for non-exported workflow functions to match the behavior in visit_mut_export_decl. Also clarify the fixture comment to distinguish step-mode and workflow-mode behavior per reviewer feedback.
* [swc-plugin] Namespace nested step IDs across all workflow declaration shapes
Extends the previous fix to cover all three non-exported workflow declaration forms (async function decl, const arrow, const fn-expr) by visiting the workflow body with workflow context before replacing it, and corrects the __internal_workflows manifest comment to report the same prefixed step IDs that are registered at runtime and looked up by the workflow-mode WORKFLOW_USE_STEP proxy. Adds a dedicated regression fixture covering all three shapes.
Signed-off-by: Nathan Rajlich <n@n8.io>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Nathan Rajlich <n@n8.io>
@github-actionsgithub-actionsBot mentioned this pull request May 22, 2026
TooTallNate added a commit that referenced this pull request May 22, 2026
The fixture was introduced by the backport of #1935 (#1945) with the
pre-namespacing step ID "step//./input//step" in the __internal_workflows
manifest comment. The subsequent backport of #1944 (#1946) shipped the
namespacing fix in lib.rs but did not update this fixture, since on main
the two PRs landed in the reverse order and #1944's diff already covered
the fixture there.
Update the expected output to match what the plugin now emits:
"step//./input//outer/step" — same value already present in main.
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.

3 participants

@TooTallNate@karthikscale3