Repository navigation
Backport #4337: [next] Fix duplicate workflow build when Next resets process.env in dev - #4426
Merged
Merged
Conversation
…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 detectedLatest commit: 3d7450e The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automated backport of #4337 to
stable(backport job run).AI recommendation: This is a targeted bug fix (patch changeset) for
@workflow/next: innext dev, Next's forced@next/envreload dropsWORKFLOW_NEXT_PRIVATE_BUILT, causing a duplicate workflow build and a leaked second file watcher. The guarded code path (!process.env.WORKFLOW_NEXT_PRIVATE_BUILTinpackages/next/src/index.ts) exists verbatim onstable, so the defect affects the maintenance line too. The change is self-contained — aglobalThis-keyed build record plus unit tests — with no new API surface or dependency onmain-only behavior.