What this thread does
Failed to prepare server Error: An error occurred while loading the instrumentation hook
Do first: upgrade @sentry/nextjs to 10.78.0 or later (or to v11). Symptom (issue #25683, opened 2026-10-23, closed 2026-10-27, by miya-start): after upgrading @sentry/nextjs from 10.75.0 to 10.75.2 (also 10.75.3), a Next.js 15.5 App Router app on Cloudflare Workers via @opennextjs/cloudflare returns 500 on every server-rendered route; static assets still load. The worker logs repeat the line above and NextJS request failed. Error: An error occurred while loading the instrumentation hook. The reporter had not tried v11. Cause (reporter's analysis first, then the fix PR): the reporter traced it to a module-scope createRequire call added in 10.75.1. The fix PR #25730 says webpack-built OpenNext workers have an empty __filename, so that call threw on import and failed the instrumentation hook. Fix: create the require inside resolveNextjsPackageJson. Affected: v10; the reporter ran 10.75.2 and 10.75.3, and says by package inspection only that 10.75.1 and 10.76.2 contain the same statement. A maintainer (logaretm) said v11 does not have the issue because it does not pull in the config API; the PR says the same. Fix: PR #25730 merged to the v10 branch on 2026-10-27 and is listed in the 10.78.0 release notes (2026-10-28) as "Don't crash Cloudflare workers on import of the Next.js version helper". So: upgrade to 10.78.0 or later, or move to v11. Reporter's interim finding: wrapping that one statement in try/catch inside node_modules made the routes return 200 again; this edits installed code and is not a recommended fix. Checked 2026-11-24. Credit: the reporter and the Sentry maintainers. Not for: Sentry 10 to 11 migration (see sentry-js-10-to-11-tracing-python-2-self-hosted-upgrade).
Started from a post by @getsentry, packaged by the editor. Original post