Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions dev-packages/e2e-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ is the reference setup.
`sentry.server.config.ts`: a runtime-specific file can replace a file but not remove it, so the build command deletes
it. Nitro turns every file under `server/api` into a route, so
`nuxt.config.ts` lists the runtime-specific files there (such as `db-mongoose.cloudflare.ts`) in Nitro's `ignore`.
`nuxt-5` (Nitro 3) has the same setup, with the `cloudflare_module` preset on Cloudflare.
- **Start commands**: `playwright.config.mjs` selects the start command with `getRuntime()`. Bun and Deno use the same build
as Node and only change the start command, for example
`bun --bun --preload ./instrument.bun.mjs ./node_modules/@react-router/serve/bin.cjs ./build/server/index.js` and
Expand Down Expand Up @@ -226,8 +227,9 @@ is the reference setup.
on `RUNTIME` and say why in a comment. An app that starts its own server can instead bundle it with
`@sentry/bun/plugin`, as `nestjs-12/bun-build.mjs` and `express-5/bun-build.mjs` do. Bun 1.3 renames classes in
bundles (`class Foo2`), which changes span names taken from class names, so `nestjs-12` pins Bun 1.4 (see #26289).
`nuxt-4` builds with `bun --bun nuxt build` on Bun, because the Nitro prerenderer loads its `bun-sqlite` connector in
the build process.
`nuxt-4` and `nuxt-5` build with `bun --bun nuxt build` on Bun, because the Nitro prerenderer loads its `bun-sqlite`
connector in the build process. On Bun, Nitro 3 selects its `bun` preset, which serves with `Bun.serve`, so the Bun
config of `nuxt-5` adds `bunServerIntegration` and not `bunHttpServerIntegration`.

```json
"sentryTest": {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script setup lang="ts">
import { useFetch } from '#imports';

// Rendering on the server fetches an internal API route, which goes through Nitro's `fetch`. On Bun, the text
// response of that `fetch` has no `content-type`, so without `responseType`, `$fetch` would parse it as JSON.
const { data } = await useFetch('/api/test-param/internal', { responseType: 'text' });
</script>

<template>
<p>{{ data }}</p>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineCloudflareOptions } from '@sentry/cloudflare';

// On Cloudflare, the Sentry Nuxt module wraps the Worker with `withSentry` and these options. Node, Bun and Deno use
// `sentry.server.config.ts`.
export default defineCloudflareOptions({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
tracesSampleRate: 1.0,
tunnel: 'http://localhost:3031/', // proxy server
// Several tests trigger the same server error one after another, which Dedupe would drop.
integrations: integrations => integrations.filter(integration => integration.name !== 'Dedupe'),
});
35 changes: 23 additions & 12 deletions dev-packages/e2e-tests/test-applications/nuxt-5/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
// The runtime variants set `RUNTIME` for the build, see dev-packages/e2e-tests/README.md.
const runtime = process.env.RUNTIME || 'node';
const cloudflare = runtime === 'cloudflare';

// `node:sqlite` is not available on Bun, which has its own SQLite module, and on Cloudflare, which has D1.
function database(name: string, binding: string) {
if (cloudflare) {
return { connector: 'cloudflare-d1', options: { bindingName: binding } } as const;
}
return { connector: runtime === 'bun' ? 'bun-sqlite' : 'sqlite', options: { name } } as const;
}

export default defineNuxtConfig({
compatibilityDate: '2025-07-15',
Expand All @@ -22,23 +33,23 @@ export default defineNuxtConfig({
},
},
nitro: {
...(cloudflare && {
// The Sentry module sets up the SDK from `instrument.server.ts`, because the Nitro preset does not use
// `sentry.server.config.ts`.
preset: 'cloudflare_module',
cloudflare: { nodeCompat: true, deployConfig: false },
}),
// Files for one runtime replace their counterpart in the copy of the app for that runtime, see
// dev-packages/e2e-tests/README.md, and are no routes of their own.
ignore: ['**/*.cloudflare.ts'],
...(process.env.E2E_TEST_CACHE_DRIVER && { cache: { driver: process.env.E2E_TEST_CACHE_DRIVER } }),
experimental: {
database: true,
},
database: {
default: {
connector: 'sqlite',
options: { name: 'db' },
},
users: {
connector: 'sqlite',
options: { name: 'users_db' },
},
analytics: {
connector: 'sqlite',
options: { name: 'analytics_db' },
},
default: database('db', 'DB'),
users: database('users_db', 'USERS_DB'),
analytics: database('analytics_db', 'ANALYTICS_DB'),
},
storage: {
'test-storage': {
Expand Down
31 changes: 29 additions & 2 deletions dev-packages/e2e-tests/test-applications/nuxt-5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"generate": "nuxt generate",
"preview": "nuxt preview",
"start": "node .output/server/index.mjs",
"start:bun": "bun .output/server/index.mjs",
"start:deno": "deno run -A .output/server/index.mjs",
"start:cloudflare": "wrangler dev --port 3030",
"start:import": "node --import ./.output/server/sentry.server.config.mjs .output/server/index.mjs",
"clean": "npx nuxi cleanup",
"test": "playwright test",
Expand All @@ -17,7 +20,9 @@
"test:build-canary": "pnpm add nuxt@npm:nuxt-nightly@latest && pnpm add nitro@npm:nitro-nightly@latest && pnpm install --force && pnpm build",
"test:assert": "pnpm test:prod && pnpm test:dev",
"test:build:kv-cache": "pnpm install && E2E_TEST_CACHE_DRIVER=kv pnpm build",
"test:assert:kv-cache": "E2E_TEST_CACHE_DRIVER=kv TEST_ENV=production playwright test cache"
"test:assert:kv-cache": "E2E_TEST_CACHE_DRIVER=kv TEST_ENV=production playwright test cache",
"test:build:bun": "pnpm install && bun --bun nuxt build",
"test:build:cloudflare": "rm sentry.server.config.ts && pnpm test:build"
},
"//": [
"Currently, we need to install the Nuxt nightlies as those contain Nuxt v5",
Expand All @@ -27,6 +32,9 @@
],
"dependencies": {
"@pinia/nuxt": "^0.11.3",
"@sentry/bun": "file:../../packed/sentry-bun-packed.tgz",
"@sentry/cloudflare": "file:../../packed/sentry-cloudflare-packed.tgz",
"@sentry/deno": "file:../../packed/sentry-deno-packed.tgz",
"@sentry/nuxt": "file:../../packed/sentry-nuxt-packed.tgz",
"db0": "^0.4.2",
"mongoose": "^9.10.2",
Expand All @@ -38,7 +46,8 @@
"devDependencies": {
"@playwright/test": "1.64.1",
"@sentry/conventions": "0.35.0",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz"
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
"wrangler": "^4.72.0"
},
"sentryTest": {
"optional": true,
Expand All @@ -55,6 +64,24 @@
"build-command": "pnpm test:build:kv-cache",
"assert-command": "pnpm test:assert:kv-cache",
"label": "nuxt-5 (kv-cache)"
},
{
"runtime": "bun",
"build-command": "pnpm test:build:bun",
"assert-command": "pnpm test:prod",
"label": "nuxt-5 (bun)"
},
{
"runtime": "deno",
"deno-version": "v2.9.0",
"assert-command": "pnpm test:prod",
"label": "nuxt-5 (deno)"
},
{
"runtime": "cloudflare",
"build-command": "pnpm test:build:cloudflare",
"assert-command": "pnpm test:prod",
"label": "nuxt-5 (cloudflare)"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
import { getPlaywrightConfig } from '@sentry-internal/test-utils';
import { getPlaywrightConfig, getRuntime } from '@sentry-internal/test-utils';

const testEnv = process.env.TEST_ENV;

if (!testEnv) {
throw new Error('No test env defined');
}

// The server config is bundled into the Nitro output, so every runtime starts the server entry without a preload.
const productionStartCommands = {
node: 'pnpm start',
bun: 'pnpm start:bun',
deno: 'pnpm start:deno',
cloudflare: 'pnpm start:cloudflare',
};

const getStartCommand = () => {
if (testEnv === 'development') {
// The Sentry server config is bundled into the dev server via a nitro plugin, so no preload is needed.
return 'nuxt dev -p 3030';
}

if (testEnv === 'production') {
return 'pnpm start';
return productionStartCommands[getRuntime()];
}

throw new Error(`Unknown test env: ${testEnv}`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
allowBuilds:
'@sentry/cli': true
esbuild: true
workerd: true
minimumReleaseAge: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { bunServerIntegration, fetchIntegration } from '@sentry/bun';
import * as Sentry from '@sentry/nuxt';

Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
tracesSampleRate: 1.0, // Capture 100% of the transactions
tunnel: 'http://localhost:3031/', // proxy server
// Several tests trigger the same server error one after another, which Dedupe would drop.
integrations: integrations => [
...integrations.filter(integration => integration.name !== 'Dedupe'),
// On Bun, Nitro 3 builds with its `bun` preset, which serves with `Bun.serve`. Bun emits none of the undici channels
// the Node SDK listens to, so these add the incoming request and outgoing `fetch` instrumentation.
bunServerIntegration(),
fetchIntegration(),
],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { fetchIntegration } from '@sentry/deno';
import * as Sentry from '@sentry/nuxt';

Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
tracesSampleRate: 1.0, // Capture 100% of the transactions
tunnel: 'http://localhost:3031/', // proxy server
// Several tests trigger the same server error one after another, which Dedupe would drop.
integrations: integrations => [
...integrations.filter(integration => integration.name !== 'Dedupe'),
// The `fetch` of Deno is not undici, so the Node SDK does not see outgoing requests.
fetchIntegration(),
],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineHandler } from 'nitro';
import { HTTPError } from 'nitro/h3';

// Replaces `db-mongoose.ts` on Cloudflare, see `MONGOOSE_UNSUPPORTED` in `tests/runtime.ts`.
export default defineHandler(() => {
throw new HTTPError({ status: 501 });
});
Loading
Loading