Skip to content

Commit c3faaeb

Browse files
JPeer264claude
andcommitted
test(nextjs): Run nextjs-16 on Bun, Deno and Cloudflare
nextjs-16 gets variants for Bun, Deno and Cloudflare Workers (OpenNext) and replaces `nextjs-16-bun` and `nextjs-16-cf-workers`. Bun, Cloudflare and Cloudflare with the latest Next.js are required jobs, as the two old apps were. Deno is optional. - Bun and Deno run `next start` on the same build as Node.js. The server config adds the integrations of `@sentry/bun` and `@sentry/deno` that replace the Node.js instrumentation these runtimes do not trigger. The e2e README now describes this, and that `variants` run as required jobs. - Cloudflare builds with `opennextjs-cloudflare` and wraps the Worker in `worker.ts` with `withSentry` from `@sentry/nextjs/cloudflare`. `pg-cloudflare` is in `serverExternalPackages`, because OpenNext copies the `workerd` build of a package only when that list has the package. - The app does not depend on `@opentelemetry/api` directly, because the OpenNext middleware bundle can not load an installed copy. `/api/otel-context` uses the copy of Next.js. - The mock AI server runs in the Playwright global setup instead of the app, because a Worker can not start a `node:http` server. Thus the OpenAI test runs on every runtime. - Tests branch on `getRuntime()` where the runtimes differ (segment origin and attributes, middleware spans in the request segment of the Worker, fetch span attributes). They skip what a runtime can not do: Node.js runtime metrics on Workers, and `pg` spans on Bun and Workers, which have no runtime module hook. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 2ac09b0 commit c3faaeb

132 files changed

Lines changed: 251 additions & 2385 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎dev-packages/e2e-tests/README.md‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,20 @@ Apps like `cloudflare-workers-send-to-sentry` deploy the built app as a real Wor
136136

137137
## Runtime variants (Bun, Deno, Cloudflare)
138138

139-
To test a framework on a runtime other than Node.js, add an `optionalVariants` entry to the existing test app instead of
140-
creating a new app. `react-router-8-framework` is the reference setup.
139+
To test a framework on a runtime other than Node.js, add a variant to the existing test app instead of creating a new
140+
app: `variants` run as required CI jobs, `optionalVariants` as optional ones. `react-router-8-framework` is the
141+
reference setup.
141142

142143
- **`RUNTIME` env var**: `node` (default), `bun`, `deno` or `cloudflare`. Read it with `getRuntime()` from
143144
`@sentry-internal/test-utils`, which throws on any other value. Tests branch on it where the runtimes are expected to
144145
differ (for example `platform` or `sdk.name`).
145146
- **SDK per runtime**: each runtime inits its own SDK, the way a user of that runtime would: Node the framework SDK
146147
(`instrument.mjs`), Bun `@sentry/bun` (`instrument.bun.mjs`), Deno `@sentry/deno` (`instrument.deno.mjs`) and
147148
Cloudflare `@sentry/cloudflare`. The framework SDK only provides the framework wrappers on the other runtimes, so
148-
values that come from its `init()` (`sdk.name`, default integrations) are Node-only.
149+
values that come from its `init()` (`sdk.name`, default integrations) are Node-only. Next.js is different: it loads
150+
`instrumentation.ts` on every runtime, so `nextjs-16` calls `init()` of `@sentry/nextjs` on Bun and Deno too, and
151+
adds the integrations of `@sentry/bun` or `@sentry/deno` that replace the Node instrumentation those runtimes do not
152+
trigger.
149153
- **Start commands**: `playwright.config.mjs` selects the start command with `getRuntime()`. Bun and Deno use the same build
150154
as Node and only change the start command, for example
151155
`bun --bun --preload ./instrument.bun.mjs ./node_modules/@react-router/serve/bin.cjs ./build/server/index.js` and

‎dev-packages/e2e-tests/test-applications/nextjs-16-bun/.gitignore‎

Lines changed: 0 additions & 44 deletions
This file was deleted.

‎dev-packages/e2e-tests/test-applications/nextjs-16-bun/app/(nested-layout)/layout.tsx‎

Lines changed: 0 additions & 12 deletions
This file was deleted.

‎dev-packages/e2e-tests/test-applications/nextjs-16-bun/app/(nested-layout)/nested-layout/[dynamic]/layout.tsx‎

Lines changed: 0 additions & 12 deletions
This file was deleted.

‎dev-packages/e2e-tests/test-applications/nextjs-16-bun/app/(nested-layout)/nested-layout/[dynamic]/page.tsx‎

Lines changed: 0 additions & 15 deletions
This file was deleted.

‎dev-packages/e2e-tests/test-applications/nextjs-16-bun/app/(nested-layout)/nested-layout/layout.tsx‎

Lines changed: 0 additions & 12 deletions
This file was deleted.

‎dev-packages/e2e-tests/test-applications/nextjs-16-bun/app/(nested-layout)/nested-layout/page.tsx‎

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎dev-packages/e2e-tests/test-applications/nextjs-16-bun/app/api/endpoint-behind-middleware/route.ts‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎dev-packages/e2e-tests/test-applications/nextjs-16-bun/app/global-error.tsx‎

Lines changed: 0 additions & 23 deletions
This file was deleted.

‎dev-packages/e2e-tests/test-applications/nextjs-16-bun/app/layout.tsx‎

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)