Skip to content

fix: preserve Nitro workflow step registration side effects#1386

Open
comfuture wants to merge 2 commits intovercel:mainfrom
comfuture:fix/nitro-step-side-effects
Open

fix: preserve Nitro workflow step registration side effects#1386
comfuture wants to merge 2 commits intovercel:mainfrom
comfuture:fix/nitro-step-side-effects

Conversation

@comfuture
Copy link

Summary

  • side-effect import generated Nitro workflow handler bundles before reading their POST export
  • keep step registration side effects alive when Nitro bundles workflow/steps.mjs
  • add a regression test for Nitro v2 and v3 virtual handlers

Why

In Nitro/Nuxt local production builds, the generated workflow/steps.mjs bundle can be treated as a pure export provider when the virtual handler only imports { POST }. That allows the step bundle's top-level registerStepFunction(...) calls to disappear from the final Nitro server bundle, which leads to runtime failures like Step \"...\" not found when a queued step executes.

Importing the generated bundle for side effects before consuming POST keeps the registration code in the final server output.

Validation

  • pnpm vitest run packages/nitro/src/index.test.ts
  • pnpm --filter @workflow/example-nuxt build
  • confirmed the built Nuxt Nitro bundle contains registerStepFunction(...) calls for app steps after this change

@comfuture comfuture requested a review from a team as a code owner March 14, 2026 04:52
@changeset-bot
Copy link

changeset-bot bot commented Mar 14, 2026

🦋 Changeset detected

Latest commit: 2d6de62

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

This PR includes changesets to release 16 packages
Name Type
@workflow/nitro Patch
@workflow/nuxt Patch
workflow Patch
@workflow/ai Patch
@workflow/world-testing Patch
@workflow/core Patch
@workflow/builders Patch
@workflow/cli Patch
@workflow/next Patch
@workflow/vitest Patch
@workflow/web-shared Patch
@workflow/astro Patch
@workflow/nest Patch
@workflow/rollup Patch
@workflow/sveltekit Patch
@workflow/vite Patch

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

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

@vercel
Copy link
Contributor

vercel bot commented Mar 14, 2026

@comfuture is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@pranaygp
Copy link
Collaborator

@VaguelySerious @pi0 what do you think?

@pranaygp pranaygp requested review from VaguelySerious and pi0 March 15, 2026 23:44
@pi0
Copy link
Collaborator

pi0 commented Mar 16, 2026

LGTM if it is delibrate to even have side effects... Is there any backstory to this? (why we need side-effects?)

Sign up for free to 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