Repository navigation
fix(next): warn at startup when installed Next.js is outside supported peer range - #17137
Open
hemraj-007 wants to merge 1 commit into
Open
hemraj-007 wants to merge 1 commit into
hemraj-007 wants to merge 1 commit into
Conversation
…d peer range Payload declares a `next` peer dependency but never enforced it at runtime, so an unsupported version produced a cryptic admin failure. withPayload now compares the resolved Next.js version against the declared peer range and logs a clear, actionable warning at startup. Closes payloadcms#17119 Co-authored-by: Cursor <[email protected]>
This branch has not been deployed
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.
What?
Adds a startup check in
withPayload()that compares the installed Next.jsversion against the
nextpeer-dependency range declared by@payloadcms/next.If the installed version falls outside that range, Payload logs a clear,
actionable warning. When the version is supported (or can't be determined), it
stays silent and never blocks the build.
New helpers in
withPayload.utils.js:getSupportedNextRange()— reads the declared peer range from the package's ownpackage.json(stays in sync automatically).satisfiesNextRange()— minimal semver range check (supports>= <and disjoint||ranges) with no runtimesemverdependency, since this runs insidenext.configbefore the build.getUnsupportedNextVersionWarning()— pure builder for the warning message.Example output:
Why?
Payload declares a
nextpeer dependency but never enforced it at runtime.Installing an unsupported version (e.g. in the 16.0.0–16.2.5 gap) produced a
cryptic "This page could not be found" admin failure with no hint that Next was
the cause. A one-line startup warning turns an opaque debugging session into an
obvious fix, and surfaces the security angle (the
>=16.2.6floor exists forsecurity reasons).
How?
withPayload()runs whennext.configloads — the single hook that fires fordev,build, andstart— and already emits other startup warnings, so thecheck lives there. The range is read from the package's own
peerDependenciesso it never drifts from what's actually published.
Fixes #17119