Skip to content

Fix duplicate transforms of Nitro build artifacts#2925

Merged
NathanColosimo merged 1 commit into
mainfrom
codex/issue-2894-repro
Jul 14, 2026
Merged

Fix duplicate transforms of Nitro build artifacts#2925
NathanColosimo merged 1 commit into
mainfrom
codex/issue-2894-repro

Conversation

@NathanColosimo

Copy link
Copy Markdown
Contributor

Summary

  • skip Workflow transforms for generated Nitro build artifacts
  • cover both the Vite and Nitro Rollup transform hooks with a regression test

Testing

  • pnpm vitest run packages/nitro/src/index.test.ts
  • pnpm --filter @workflow/nitro build
  • reproduced and verified the fix with TanStack Start, ssr.noExternal: true, and @ai-sdk/gateway@4.0.16

Closes #2894

@changeset-bot

changeset-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: aaa603e

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/world-testing Patch
@workflow/core Patch
@workflow/builders Patch
@workflow/cli Patch
@workflow/next Patch
@workflow/vitest Patch
@workflow/web-shared Patch
@workflow/web 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

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview, Comment Jul 14, 2026 9:39pm
example-nextjs-workflow-webpack Ready Ready Preview, Comment Jul 14, 2026 9:39pm
example-workflow Ready Ready Preview, Comment Jul 14, 2026 9:39pm
workbench-astro-workflow Ready Ready Preview, Comment Jul 14, 2026 9:39pm
workbench-express-workflow Ready Ready Preview, Comment Jul 14, 2026 9:39pm
workbench-fastify-workflow Ready Ready Preview, Comment Jul 14, 2026 9:39pm
workbench-hono-workflow Ready Ready Preview, Comment Jul 14, 2026 9:39pm
workbench-nitro-workflow Ready Ready Preview, Comment Jul 14, 2026 9:39pm
workbench-nuxt-workflow Ready Ready Preview, Comment Jul 14, 2026 9:39pm
workbench-sveltekit-workflow Ready Ready Preview, Comment Jul 14, 2026 9:39pm
workbench-tanstack-start-workflow Ready Ready Preview, Comment Jul 14, 2026 9:39pm
workbench-vite-workflow Ready Ready Preview, Comment Jul 14, 2026 9:39pm
workflow-docs Ready Ready Preview, Comment, Open in v0 Jul 14, 2026 9:39pm
workflow-swc-playground Ready Ready Preview, Comment Jul 14, 2026 9:39pm
workflow-tarballs Ready Ready Preview, Comment Jul 14, 2026 9:39pm
workflow-web Ready Ready Preview, Comment Jul 14, 2026 9:39pm

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

Passed Failed Skipped Total
✅ ▲ Vercel Production 1453 0 230 1683
✅ 💻 Local Development 1617 0 219 1836
✅ 📦 Local Production 1617 0 219 1836
✅ 🐘 Local Postgres 1617 0 219 1836
✅ 🪟 Windows 153 0 0 153
✅ 📋 Other 894 0 177 1071
✅ vercel-multi-region 27 0 0 27
Total 7378 0 1064 8442

Details by Category

✅ ▲ Vercel Production
App Passed Failed Skipped
✅ astro 126 0 27
✅ example 126 0 27
✅ express 126 0 27
✅ fastify 126 0 27
✅ hono 126 0 27
✅ nextjs-turbopack 150 0 3
✅ nextjs-webpack 150 0 3
✅ nitro 126 0 27
✅ nuxt 126 0 27
✅ sveltekit 145 0 8
✅ vite 126 0 27
✅ 💻 Local Development
App Passed Failed Skipped
✅ astro-stable 128 0 25
✅ express-stable 128 0 25
✅ fastify-stable 128 0 25
✅ hono-stable 128 0 25
✅ nextjs-turbopack-canary 134 0 19
✅ nextjs-turbopack-stable 153 0 0
✅ nextjs-webpack-canary 134 0 19
✅ nextjs-webpack-stable 153 0 0
✅ nitro-stable 128 0 25
✅ nuxt-stable 128 0 25
✅ sveltekit-stable 147 0 6
✅ vite-stable 128 0 25
✅ 📦 Local Production
App Passed Failed Skipped
✅ astro-stable 128 0 25
✅ express-stable 128 0 25
✅ fastify-stable 128 0 25
✅ hono-stable 128 0 25
✅ nextjs-turbopack-canary 134 0 19
✅ nextjs-turbopack-stable 153 0 0
✅ nextjs-webpack-canary 134 0 19
✅ nextjs-webpack-stable 153 0 0
✅ nitro-stable 128 0 25
✅ nuxt-stable 128 0 25
✅ sveltekit-stable 147 0 6
✅ vite-stable 128 0 25
✅ 🐘 Local Postgres
App Passed Failed Skipped
✅ astro-stable 128 0 25
✅ express-stable 128 0 25
✅ fastify-stable 128 0 25
✅ hono-stable 128 0 25
✅ nextjs-turbopack-canary 134 0 19
✅ nextjs-turbopack-stable 153 0 0
✅ nextjs-webpack-canary 134 0 19
✅ nextjs-webpack-stable 153 0 0
✅ nitro-stable 128 0 25
✅ nuxt-stable 128 0 25
✅ sveltekit-stable 147 0 6
✅ vite-stable 128 0 25
✅ 🪟 Windows
App Passed Failed Skipped
✅ nextjs-turbopack 153 0 0
✅ 📋 Other
App Passed Failed Skipped
✅ e2e-local-dev-nest-stable 128 0 25
✅ e2e-local-dev-tanstack-start- 128 0 25
✅ e2e-local-postgres-nest-stable 128 0 25
✅ e2e-local-postgres-tanstack-start- 128 0 25
✅ e2e-local-prod-nest-stable 128 0 25
✅ e2e-local-prod-tanstack-start- 128 0 25
✅ e2e-vercel-prod-tanstack-start 126 0 27
✅ vercel-multi-region
App Passed Failed Skipped
✅ nextjs-turbopack 27 0 0

📋 View full workflow run

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

📊 Workflow Benchmarks

commit aaa603e · Tue, 14 Jul 2026 21:56:02 GMT · run logs

Backend: vercel · app: nextjs-turbopack

Metric Scenario Avg (ms) P75 (ms) P90 (ms) P99 (ms) Samples
TTFS stream 1226 (-9.8%) 1690 🔴 1768 🔴 1903 🔴 30
TTFS hook + stream 1645 (+2.6%) 1907 🔴 1987 🔴 2138 🔴 30
STSO 1020 steps (1-20) 263 (-6.9%) 288 🔴 345 🔴 351 🔴 19
STSO 1020 steps (101-120) 432 (-3.1%) 486 🔴 739 🔴 741 🔴 19
STSO 1020 steps (1001-1020) 868 (+4.1%) 931 🔴 1024 🔴 1172 🔴 19
WO stream 1226 (-9.8%) 1690 1768 1903 30
WO hook + stream 1645 (+2.6%) 1907 1987 2138 30
SL stream 4148 (-14%) 5726 🔴 5844 🔴 6190 🔴 30
SL hook + stream 4739 (±0%) 5153 🔴 5663 🔴 5806 🔴 30

Avg deltas compare against the most recent benchmark run on main at the time of this run.

Metrics — TTFS: time to first step body execution · STSO: step-to-step overhead (gap between consecutive step bodies) · WO: workflow overhead (time outside step bodies, client start → last step body exit) · SL: stream latency (first chunk write → visible to the reader)

Scenarios — stream: one step that streams chunks back to the client; no hooks, so the run stays in turbo mode · hook + stream: registers a hook before the same streaming step, which exits turbo mode · 1020 steps: 1020 trivial sequential steps; STSO is measured between consecutive steps in the given step ranges

🟢/🔴 mark percentiles within/above target. Targets (p75/p90/p99, ms) — TTFS 200/300/600 · SL 50/60/125 · STSO (1-20) 20/30/60 · STSO (101-120) 30/45/90 · STSO (1001-1020) 40/60/120

TTFS/WO compare client vs deployment clocks and SL compares the step runner’s clock vs the client’s (NTP-synced in CI). WO ends at the last step body exit, the closest observable proxy for the final step-completion request.

@TooTallNate TooTallNate left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the fix, the exclusion mechanics, and the tests. Approving.

The widening is principled, not a spot fix. Excluding all of buildDir/ (instead of just buildDir/workflow) is the right boundary: everything under Nitro's build directory is generated output — either already-transformed chunks (the re-registration crash from #2894) or build machinery — and user source never lives there, so there's nothing legitimate left to transform. It also strictly subsumes the old exclusion, so the previous failure mode that exclusion guarded ("undefined class references when Nitro's bundler renames variables") stays covered.

Mechanics verified against @workflow/rollup's matcher: exclude entries are prefix-matched after normalizing backslashes on both sides, so the raw replace(/[\\/]+$/, '') + '/' construction (replacing the old pathe join) is cross-platform safe, and the appended trailing slash prevents sibling-directory false positives (/tmp/.nitro-source staying transformed while /tmp/.nitro/... is skipped) — which the regression test pins explicitly. Nice detail that the test drives both transform surfaces (the lazy Vite plugin and the rollup:before plugin) through the real nitro.setup path with a serde class — the actual crash vector — rather than testing the exclusion list in isolation.

Verified locally: 33/33 nitro tests pass (my initial single failure was a worktree artifact — the pre-existing world-target alias test needs @workflow/world-postgres built; unrelated to this change). CI is fully green, including every nitro/nuxt/tanstack-start/vite lane across dev, prod, and postgres — which also empirically answers the one risk I checked for (dev-mode workflow discovery surviving the wider exclusion). Changeset is a correct @workflow/nitro patch.

One non-blocking defense-in-depth thought: this fixes the duplicate transform at the Nitro layer, but the crash mechanism — a second registration IIFE calling a non-configurable defineProperty(classId), with a wrong chunk-path-derived id to boot — will reproduce identically in any future pipeline that re-feeds transformed output. The SWC-emitted registration could be made resilient (skip or alias when the class already carries a classId, similar to how aliasSerializationClass sidesteps the redefine-throw) so the failure mode degrades to a benign no-op instead of 500ing every SSR request. Worth a follow-up issue if one doesn't exist.

@NathanColosimo
NathanColosimo merged commit c44b4f8 into main Jul 14, 2026
171 of 174 checks passed
@NathanColosimo
NathanColosimo deleted the codex/issue-2894-repro branch July 14, 2026 22:37
github-actions Bot added a commit that referenced this pull request Jul 14, 2026
Signed-off-by: Nathan Colosimo <110621881+NathanColosimo@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

Backport PR opened against stable: #2928. Merge conflicts were resolved by AI — please review carefully. (backport job run)

NathanColosimo pushed a commit that referenced this pull request Jul 14, 2026
Signed-off-by: Nathan Colosimo <110621881+NathanColosimo@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

Nitro-in-Vite: intermediate chunks re-transformed, duplicate class registration crashes SSR with "Cannot redefine property: classId"

2 participants