Skip to content

fix(patches): return empty object for unhandled manifests in loadManifest#1151

Open
nathanschram wants to merge 2 commits intoopennextjs:mainfrom
nathanschram:fix/load-manifest-graceful-fallback
Open

fix(patches): return empty object for unhandled manifests in loadManifest#1151
nathanschram wants to merge 2 commits intoopennextjs:mainfrom
nathanschram:fix/load-manifest-graceful-fallback

Conversation

@nathanschram
Copy link

Summary

  • Return {} instead of throwing for manifest paths not found during the build-time glob scan in loadManifest() and evalManifest()
  • Handles Next.js 16.2.0-canary.53+ which introduces new loadManifest() calls for optional/phase-dependent manifests

Problem

Next.js canary adds loadManifest() calls for:

  1. subresource-integrity-manifest.json - only generated when experimental.sri is configured, but loaded unconditionally
  2. Per-route react-loadable-manifest.json - generated by Turbopack, possibly in a different build phase

The adapter's build-time glob scan doesn't find these files, so the patched function throws at runtime, crashing all dynamic routes with 500.

Fix

Replace the throw new Error('Unexpected loadManifest...') fallback with return {}. This follows the same defensive pattern used by other adapter plugins (instrumentation.ts, find-dir.ts) that return safe defaults for missing files.

Test plan

  • Build a Next.js app with next@canary (16.2.0-canary.53+) using @opennextjs/cloudflare
  • Verify dynamic/SSR routes no longer return 500
  • Verify existing manifests still load correctly (app-manifest, build-manifest, etc.)
  • Verify SRI works correctly when experimental.sri IS configured

Fixes #1141

@changeset-bot
Copy link

changeset-bot bot commented Feb 25, 2026

🦋 Changeset detected

Latest commit: 5c0f1be

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

@nathanschram
Copy link
Author

Hey @vicb - just wanted to check in on this. No rush at all, I know you're probably busy. Just wanted to make sure the approach looks reasonable to you, or if you'd prefer I take it in a different direction. Happy to adjust anything.

@Rovak
Copy link

Rovak commented Mar 19, 2026

Can confirm that is working for me in production after copying this patch into the project using pnpm patch

@bonadio
Copy link

bonadio commented Mar 20, 2026

Need this fix too.
Thanks

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] Unexpected loadManifest calls for new manifest files introduced in Next.js 16.2.0-canary

3 participants