Repository navigation
@sentry/nextjs server entry re-exports withSentryConfig, pulling the orchestrion webpack plugin's WASM into the runtime bundle (CompileError on Cloudflare Workers) #22794
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/nextjs
SDK Version
10.68.0
Framework Version
Next.js 16.2.11, @opennextjs/cloudflare 1.20.2, node 26.2.0, workerd compatibility_date 2026-04-14
Link to Sentry event
Private project — full stack and tags reproduced below.
Reproduction Example/SDK Setup
A Next.js app deployed to Cloudflare Workers via OpenNext, with the standard instrumentation.ts setup:
// src/instrumentation.ts
import * as Sentry from "@sentry/nextjs";
export async function register() {
if (process.env.NEXT_RUNTIME === "nodejs") {
await import("../sentry.server.config");
}
}Steps to Reproduce
import * as Sentry from "@sentry/nextjs"from any server module (instrumentation.ts,sentry.server.config.ts, a route handler).- Build for Cloudflare Workers (
opennextjs-cloudflare build) and deploy. - Trigger a cold start — any request will do.
Expected Result
The runtime bundle contains only runtime code. Nothing attempts WebAssembly.compile() at module-evaluation time, since Cloudflare Workers
forbids runtime WASM compilation.
Actual Result
Every cold start raises an unhandled promise rejection:
CompileError: WebAssembly.compile(): Wasm code generation disallowed by embedder
at Context.commonJsRequire
at getOrInstantiateModuleFromParent
at instantiateModule
at module evaluation
Tagged unhandledPromiseRejection: true, with no route frames — the stack is
module evaluation only. In our project this produced 50 events over four days,
one per cold start, attributed to whichever request happened to warm the
isolate (44 of 50 have an empty transaction tag).
Root cause
@sentry/nextjs's server runtime entry re-exports the build-time config
helper, and that export's module graph reaches a bundler plugin containing an
inlined WASM module:
node_modules/@sentry/nextjs/build/esm/index.server.js:1
export { withSentryConfig } from './config/withSentryConfig/index.js';
-> config/withSentryConfig/buildTime.js:4,6
import { getTracingHooksDirectory } from '@sentry/server-utils/orchestrion/webpack';
import { sentryOrchestrionWebpackPlugin } from '@sentry/server-utils/orchestrion/webpack';
-> @sentry/server-utils/build/esm/orchestrion/bundler/webpack.js
-> @apm-js-collab/[email protected]
The plugin compiles an inlined base64 WASM module (a CJS/ESM lexer) at module**
**scope, unawaited:
g = WebAssembly.compile(d()).then(WebAssembly.instantiate).then(({exports: e}) => { u = e })On Node that promise resolves and nobody notices. On Workers WebAssembly.compile
throws, and because the promise is never awaited it surfaces as an unhandled
rejection during module evaluation — with a stack that names no application code,
which makes it quite hard to attribute.
@sentry/cloudflare is not the culprit: build/esm/sdk.js:33-39 explicitly reads
channel integrations off a global marker rather than importing them, with a comment
saying this is "so bundles built without the plugin don't ship the code." That part
works as designed. The leak is the Next.js server entry.
What I verified
- The only dependency path to the plugin is
@sentry/cloudflare -> @sentry/server-utils -> @apm-js-collab/[email protected], but the inclusion comes from the import chain above. .next/servercontains the plugin in 12 chunks, including the base64 WASM blob.- Control build: removing
withSentryConfigfromnext.config.tsentirely and rebuilding leaves all 12 chunks unchanged. The build-time config file is not what pulls it in — importing@sentry/nextjsfrom a server module is. @sentry/server-utils' main entry does not reach the plugin (it is confined to the./orchestrion/*subpath exports), and the./orchestrionbarrel re-exports only channel integrations. So the subpath import inbuildTime.jsis the single crossing point.
Why this may matter beyond Workers
#22632 states the design assumption directly: "orchestrion only ships via @sentry/node/{vite,webpack,rollup,esbuild} and framework server builds." That
assumption doesn't hold here — withSentryConfig sitting on index.server.js
puts the webpack plugin one import * as Sentry from "@sentry/nextjs" away from
any server bundle. Cloudflare Workers just makes it loud, because runtime WASM
compilation is a hard error there. Elsewhere it is silent bundle weight.
Suggested fix
Move withSentryConfig off the runtime server entry, or make config/withSentryConfig/buildTime.js import the bundler plugin lazily
(await import(...) inside the function that uses it) so the WASM module isn't
reachable from module-evaluation of the runtime entry.
Workaround for others hitting this
Alias @sentry/server-utils/orchestrion/* to an empty module in the Worker build,
or import the runtime pieces from @sentry/cloudflare instead of @sentry/nextjs
where possible.
Metadata
Metadata
Assignees
Projects
- StatusShow more project fieldsNo status
Activity
linear-code commentedon Jul 29, 2026
JS-3216
chargome commentedon Jul 29, 2026
@isaacrowntree thanks for raising, we'll look into it!
fix(v10/nextjs): Fix SDK import crashing under jsdom/happy-dom (#23906)
test(e2e): Assert Next.js Cloudflare worker bundle stays free of orch…
harry-gocity commentedon Sep 7, 2026
Hey @chargome I saw #23667 merged a couple of weeks ago and made it into 10.72. I was hoping that would be the fix for this - we are running into the same issue, but after an upgrade to 10.73, the issue persists. Is there any more work known to be needed here? We're using Next.js 16.2.11 or 16.3.3 for reference.
chargome commentedon Sep 7, 2026
@harry-gocity I believe the real fix for this is #23628, mind trying out our v11 beta?
harry-gocity commentedon Sep 7, 2026
Thanks @chargome - I'm not seeing the issue with 11.0.0-beta.1.
I thought I would try updating the import with v10 since it's present in 10.73, but the error still appeared. Do you have a rough timeline for the v11 release?
chargome commentedon Sep 7, 2026
@harry-gocity yes this is because the config code is still shipped from the server file in v10 (we cannot remove it bc it is a breaking change)
v11 will likely land next week!
chargome commentedon Sep 8, 2026
Closing this for now, as there is a solution going forward