Skip to content

fix(patches): include prefetch-hints.json in loadManifest glob for Next.js 16.2#1160

Merged
petebacondarwin merged 2 commits intoopennextjs:mainfrom
matthewvolk:fix/prefetch-hints-manifest
Mar 23, 2026
Merged

fix(patches): include prefetch-hints.json in loadManifest glob for Next.js 16.2#1160
petebacondarwin merged 2 commits intoopennextjs:mainfrom
matthewvolk:fix/prefetch-hints-manifest

Conversation

@matthewvolk
Copy link
Contributor

@matthewvolk matthewvolk commented Mar 20, 2026

Problem

Next.js 16.2.0 introduced prefetch-hints.json, a new server manifest loaded unconditionally by NextNodeServer.getPrefetchHints(). The file exists in .next/server/ and is listed in required-server-files.json, but the glob pattern in load-manifest.ts only matches *-manifest.json and required-server-files.json — so no if/else branch is generated for it and the patched loadManifest() throws at runtime:

Unexpected loadManifest(/.next/server/prefetch-hints.json) call!

Why this is needed alongside #1151

PR #1151 adds graceful return {} fallbacks for optional manifests — ones Next.js loads with handleMissing: true (e.g. subresource-integrity-manifest.json, react-loadable-manifest.json). Those files may or may not exist at build time, and Next.js handles missing responses gracefully.

prefetch-hints.json is different: it is a required manifest that always exists in the build output and is loaded without handleMissing: true. It simply doesn't match the *-manifest.json glob pattern because its filename doesn't end with -manifest. The correct fix is to include it in the glob so its contents are inlined at build time, not to return an empty object at runtime.

Note: This fix alone is not sufficient for full Next.js 16.2.0 support on Workers. It also requires #1151 (optional manifest fallbacks) and a fix for extensionless manifest paths — some manifests like dynamic-css-manifest and subresource-integrity-manifest are requested without the .json extension, which causes the current $PATH.endsWith(...) checks to miss them (see comment on #1151).

Fix

Add prefetch-hints to the existing glob alternation in load-manifest.ts. This follows the same pattern used when required-server-files was added to the glob. Backwards compatible with Next.js 15/16.1.x where the file doesn't exist (glob simply finds no match).

Fixes #1157. Related: #1141, #1151.

@changeset-bot
Copy link

changeset-bot bot commented Mar 20, 2026

🦋 Changeset detected

Latest commit: 8dfcca3

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

This PR includes changesets to release 1 package
Name Type
@opennextjs/cloudflare 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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 21, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@opennextjs/cloudflare@1160

commit: 8dfcca3

Copy link
Collaborator

@conico974 conico974 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the fix, could you just fix the prettier check please ?

HazemKhaled added a commit to HazemKhaled/evisa that referenced this pull request Mar 21, 2026
Copy link
Collaborator

@sommeeeer sommeeeer left a comment

Choose a reason for hiding this comment

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

LGTM

@matthewvolk matthewvolk force-pushed the fix/prefetch-hints-manifest branch from bfef748 to 8dfcca3 Compare March 23, 2026 17:38
@matthewvolk
Copy link
Contributor Author

Thanks @conico974 and @sommeeeer for the quick review! I just pushed a fix for formatting. It looks like I don't have permissions to merge this PR on my end. Y'all mind pressing "Squash & Merge" for me (or whatever merge option you prefer)?

@petebacondarwin petebacondarwin merged commit 161e726 into opennextjs:main Mar 23, 2026
7 checks passed
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.

[BUG] Next.js 16.2.0 crashes on Cloudflare Workers (Error 1101): Unexpected loadManifest(/.next/server/prefetch-hints.json) call!

4 participants