Skip to content

Backport #4337: [next] Fix duplicate workflow build when Next resets process.env in dev - #4426

Merged
pranaygp merged 1 commit into
stablefrom
backport/pr-4337-to-stable
Sep 25, 2026
Merged

pranaygp merged 1 commit into
stablefrom
backport/pr-4337-to-stable

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Automated backport of #4337 to stable (backport job run).

AI recommendation: This is a targeted bug fix (patch changeset) for @workflow/next: in next dev, Next's forced @next/env reload drops WORKFLOW_NEXT_PRIVATE_BUILT, causing a duplicate workflow build and a leaked second file watcher. The guarded code path (!process.env.WORKFLOW_NEXT_PRIVATE_BUILT in packages/next/src/index.ts) exists verbatim on stable, so the defect affects the maintenance line too. The change is self-contained — a globalThis-keyed build record plus unit tests — with no new API surface or dependency on main-only behavior.

…ev (#4337)

* [next] Add failing test for duplicate workflow build in next dev

Co-Authored-By: Claude <noreply@anthropic.com>

Co-Authored-By: Pranay Prakash <1797812+pranaygp@users.noreply.github.com>

* [next] Build workflows once per process even if Next resets process.env

Co-Authored-By: Claude <noreply@anthropic.com>

Co-Authored-By: Pranay Prakash <1797812+pranaygp@users.noreply.github.com>

* [next] Address review: broaden cause comment, harden build record, add tests

- Document the broader trigger for the forced @next/env reload (any env
  change the dev watcher sees, incl. client router filter changes when app
  routes are added/removed), and why the record lives on globalThis.
- Rename the global key to `@workflow/next/workflowBuilds`, since it holds
  started/in-flight builds rather than finished ones.
- Only drop a failed build from the record if it is still the current one.
- Test retry after a failed build and dedupe across a plugin re-import.

Co-Authored-By: Claude <noreply@anthropic.com>

Co-Authored-By: Peter Wielander <29887157+VaguelySerious@users.noreply.github.com>

---------

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Co-authored-by: Pranay Prakash <1797812+pranaygp@users.noreply.github.com>
Co-authored-by: Peter Wielander <29887157+VaguelySerious@users.noreply.github.com>
Co-authored-by: Peter Wielander <mittgfu@gmail.com>
Signed-off-by: Pranay Prakash <pranay.gp@gmail.com>
@changeset-bot

changeset-bot Bot commented Sep 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3d7450e

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

This PR includes changesets to release 16 packages
Name Type
@workflow/next Patch
workflow Patch
@workflow/world-testing Patch
@workflow/core Patch
@workflow/builders Patch
@workflow/cli Patch
@workflow/nitro 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
@workflow/nuxt 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

@pranaygp
pranaygp merged commit 304e5dc into stable Sep 25, 2026
22 of 23 checks passed
@pranaygp
pranaygp deleted the backport/pr-4337-to-stable branch September 25, 2026 19:07
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.

1 participant