Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
export default defineNuxtConfig({
compatibilityDate: '2025-06-06',
modules: ['@sentry/nuxt/module'],
// The tunnel variant serves the app, and so the tunnel, under a base URL.
...(process.env.E2E_TEST_TUNNEL && { app: { baseURL: '/app/' } }),
nitro: {
preset: 'cloudflare_module',
cloudflare: {
Expand All @@ -16,9 +14,5 @@ export default defineNuxtConfig({
alias: {
'readable-stream': 'node:stream',
},
// The tunnel variant serves the managed tunnel.
replace: {
__E2E_TEST_TUNNEL__: JSON.stringify(!!process.env.E2E_TEST_TUNNEL),
},
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
"preview": "wrangler dev --var \"E2E_TEST_DSN:$E2E_TEST_DSN\" --port 3030 --log-level=$(test $CI && echo 'none' || echo 'log')",
"test": "playwright test",
"test:build": "pnpm install && pnpm build",
"test:assert": "pnpm test",
"test:build:tunnel": "pnpm install && E2E_TEST_TUNNEL=1 pnpm build",
"test:assert:tunnel": "E2E_TEST_TUNNEL=1 pnpm test tunnel"
"test:assert": "pnpm test"
},
"dependencies": {
"@sentry/nuxt": "file:../../packed/sentry-nuxt-packed.tgz",
Expand All @@ -22,14 +20,5 @@
"@playwright/test": "1.64.1",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
"wrangler": "^4.72.0"
},
"sentryTest": {
"variants": [
{
"build-command": "pnpm test:build:tunnel",
"assert-command": "pnpm test:assert:tunnel",
"label": "nuxt-4-cloudflare (tunnel)"
}
]
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import { defineNitroPlugin } from '#imports';
import { serveTunnelIntegration } from '@sentry/cloudflare';
import { sentryCloudflareNitroPlugin } from '@sentry/nuxt/module/plugins';

declare const __E2E_TEST_TUNNEL__: boolean;

export default defineNitroPlugin(
sentryCloudflareNitroPlugin({
// The tunnel forwards to the DSN host, which is the event proxy in the tunnel variant.
dsn: __E2E_TEST_TUNNEL__ ? 'http://public@localhost:3031/1337' : 'https://public@dsn.ingest.sentry.io/1337',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
tracesSampleRate: 1.0,
tunnel: 'http://localhost:3031/', // proxy server
integrations: __E2E_TEST_TUNNEL__ ? [serveTunnelIntegration()] : [],
}),
);

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<h1>Nuxt Tunnel E2E Test</h1>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export default defineNuxtConfig({
compatibilityDate: '2025-06-06',
modules: ['@sentry/nuxt/module'],
app: { baseURL: '/app/' },
// A headers rule on every path, like a security headers setup, also covers the tunnel's path.
routeRules: { '/**': { headers: { 'x-e2e-route-rule': '1' } } },
nitro:
process.env.RUNTIME === 'cloudflare'
? {
preset: 'cloudflare_module',
cloudflare: { nodeCompat: true, deployConfig: false },
// Cloudflare has no server config file, the SDK is set up by this plugin.
plugins: ['~~/server/sentry-cloudflare.ts'],
}
: {},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "nuxt-4-tunnel",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"start": "node .output/server/index.mjs",
"start:cloudflare": "wrangler dev --port 3030",
"clean": "npx nuxi cleanup",
"test:build": "pnpm install && pnpm build",
"test:assert": "TEST_ENV=production playwright test && TEST_ENV=development playwright test"
},
"dependencies": {
"@sentry/cloudflare": "file:../../packed/sentry-cloudflare-packed.tgz",
"@sentry/nuxt": "file:../../packed/sentry-nuxt-packed.tgz",
"nuxt": "^4.6.0"
},
"devDependencies": {
"@playwright/test": "1.64.1",
"@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz",
"wrangler": "^4.72.0"
},
"sentryTest": {
"variants": [
{
"runtime": "cloudflare",
"build-command": "rm sentry.server.config.ts && pnpm test:build",
"assert-command": "TEST_ENV=production pnpm exec playwright test",
"label": "nuxt-4-tunnel (cloudflare)"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { getPlaywrightConfig, getRuntime } from '@sentry-internal/test-utils';

export default getPlaywrightConfig({
startCommand:
process.env.TEST_ENV === 'development'
? 'pnpm exec nuxt dev -p 3030'
: getRuntime() === 'cloudflare'
? 'pnpm start:cloudflare'
: 'pnpm start',
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
allowBuilds:
esbuild: true
workerd: true
minimumReleaseAge: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as Sentry from '@sentry/nuxt';

Sentry.init({
dsn: 'http://public@localhost:3031/1337',
tunnel: true,
integrations: [Sentry.browserTracingIntegration()],
tracesSampleRate: 1,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as Sentry from '@sentry/nuxt';

Sentry.init({
dsn: 'http://public@localhost:3031/1337',
integrations: [Sentry.serveTunnelIntegration()],
tracesSampleRate: 1,
});
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { defineEventHandler } from '#imports';

export default defineEventHandler(() => ({ ok: true }));
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineEventHandler } from '#imports';

export default defineEventHandler(() => {
throw new Error('Tunnel test error');
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { createError, defineEventHandler, getHeader } from '#imports';

export default defineEventHandler(event => {
if (event.method === 'POST' && getHeader(event, 'x-auth') !== 'ok') {
throw createError({ statusCode: 401, statusMessage: 'blocked by user auth' });
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineNitroPlugin } from '#imports';
import { serveTunnelIntegration } from '@sentry/cloudflare';
import { sentryCloudflareNitroPlugin } from '@sentry/nuxt/module/plugins';

export default defineNitroPlugin(
sentryCloudflareNitroPlugin({
dsn: 'http://public@localhost:3031/1337',
integrations: [serveTunnelIntegration()],
tracesSampleRate: 1,
}),
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { startEventProxyServer } from '@sentry-internal/test-utils';

startEventProxyServer({
port: 3031,
proxyServerName: 'nuxt-4-tunnel',
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { expect, test } from '@playwright/test';
import { getRuntime, waitForError } from '@sentry-internal/test-utils';

test('keeps the body of a request that is not a tunnel request off its error event', async ({ request }) => {
test.skip(getRuntime() !== 'cloudflare', 'Only the Cloudflare plugin decides which request bodies it passes on');
const errorPromise = waitForError(
'nuxt-4-tunnel',
event => event.exception?.values?.[0]?.value === 'Tunnel test error',
);

await request.post('/app/api/error', { data: { note: 'stays off the event' }, headers: { 'x-auth': 'ok' } });
const error = await errorPromise;

expect(error.request?.method).toBe('POST');
expect(error.request?.data).toBeUndefined();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { expect, test } from '@playwright/test';
import { getRuntime } from '@sentry-internal/test-utils';
import { runManagedTunnelSuite } from '@sentry-internal/test-utils/tunnel-suite';

// On Nitro v2, `sentryCloudflareNitroPlugin` checks for a tunnel request before the SDK has a client, so it never
// passes the request body on and the app answers the tunnel instead.
test.fixme(getRuntime() === 'cloudflare', 'The managed tunnel is not served on Cloudflare yet');

test.beforeAll(async ({ request }) => {
// `nuxt dev` opens the port before it's ready and answers 503 until then, and Playwright only waits for the port.
await expect.poll(async () => (await request.get('/app/')).status(), { timeout: 30_000 }).not.toBe(503);
});

runManagedTunnelSuite({ appName: 'nuxt-4-tunnel', basePath: '/app' });
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "nuxt-4-tunnel",
"main": "./.output/server/index.mjs",
"compatibility_date": "2026-06-29",
"compatibility_flags": ["nodejs_compat"],
"assets": { "directory": "./.output/public", "binding": "ASSETS" },
}
10 changes: 1 addition & 9 deletions dev-packages/e2e-tests/test-applications/nuxt-4/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
const tunnelVariant = !!process.env.E2E_TEST_TUNNEL;

export default defineNuxtConfig({
compatibilityDate: '2025-06-06',
Expand All @@ -13,21 +12,14 @@ export default defineNuxtConfig({
'/rendering-modes/swr-cached-page': { swr: true },
'/rendering-modes/swr-1h-cached-page': { swr: 3600 },
'/rendering-modes/pre-rendered-page': { prerender: true },
// A headers rule on every path, like a security headers setup, also covers the tunnel's path.
...(tunnelVariant && { '/**': { headers: { 'x-e2e-route-rule': '1' } } }),
},

// The base-path variant serves the app, and so the tunnel, under `/app`.
...(process.env.E2E_TEST_BASE_PATH && { app: { baseURL: `${process.env.E2E_TEST_BASE_PATH}/` } }),

modules: ['@pinia/nuxt', '@sentry/nuxt/module'],
runtimeConfig: {
public: {
sentry: {
// The tunnel variant forwards to the test proxy, so the DSN has to point there.
dsn: tunnelVariant ? 'http://public@localhost:3031/1337' : 'https://public@dsn.ingest.sentry.io/1337',
dsn: 'https://public@dsn.ingest.sentry.io/1337',
},
e2eTunnel: tunnelVariant,
},
},
nitro: {
Expand Down
15 changes: 1 addition & 14 deletions dev-packages/e2e-tests/test-applications/nuxt-4/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
"test:build": "pnpm install && node ./scripts/build-with-prerender-event-sink.mjs",
"test:build-canary": "pnpm add nuxt@npm:nuxt-nightly@latest && pnpm add nitropack@npm:nitropack-nightly@latest && pnpm install --force && node ./scripts/build-with-prerender-event-sink.mjs",
"test:assert": "pnpm test:prod && pnpm test:dev",
"test:prod:import": "TEST_ENV=production-import playwright test",
"test:build:tunnel-basepath": "pnpm install && E2E_TEST_TUNNEL=1 E2E_TEST_BASE_PATH=/app node ./scripts/build-with-prerender-event-sink.mjs",
"test:assert:tunnel-basepath": "E2E_TEST_TUNNEL=1 E2E_TEST_BASE_PATH=/app TEST_ENV=production playwright test tunnel",
"test:assert:tunnel-basepath-dev": "E2E_TEST_TUNNEL=1 E2E_TEST_BASE_PATH=/app TEST_ENV=development playwright test tunnel"
"test:prod:import": "TEST_ENV=production-import playwright test"
},
"//": "Pin ioredis to 5.10.1 because that's the last version before it publishes its own diagnostics channels",
"dependencies": {
Expand All @@ -46,16 +43,6 @@
"build-command": "E2E_TEST_VITE_SERVER=true pnpm test:build",
"assert-command": "E2E_TEST_VITE_SERVER=true pnpm test:prod",
"label": "nuxt-4 (Vite server)"
},
{
"build-command": "pnpm test:build:tunnel-basepath",
"assert-command": "pnpm test:assert:tunnel-basepath",
"label": "nuxt-4 (tunnel-basepath)"
},
{
"build-command": "pnpm install",
"assert-command": "pnpm test:assert:tunnel-basepath-dev",
"label": "nuxt-4 (tunnel-basepath-dev)"
}
],
"canaryVariants": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { usePinia, useRuntimeConfig } from '#imports';

Sentry.init({
dsn: useRuntimeConfig().public.sentry.dsn,
tunnel: useRuntimeConfig().public.e2eTunnel ? true : `http://localhost:3031/`, // proxy server
tunnel: `http://localhost:3031/`, // proxy server
tracesSampleRate: 1.0,
integrations: [
Sentry.piniaIntegration(usePinia(), {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import * as Sentry from '@sentry/nuxt';

Sentry.init({
dsn: process.env.E2E_TEST_TUNNEL ? 'http://public@localhost:3031/1337' : 'https://public@dsn.ingest.sentry.io/1337',
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'),
...(process.env.E2E_TEST_TUNNEL ? [Sentry.serveTunnelIntegration()] : []),
],
integrations: integrations => [...integrations.filter(integration => integration.name !== 'Dedupe')],
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { createError, defineEventHandler, getHeader, setHeader, getQuery } from '#imports';
import { defineEventHandler, setHeader, getQuery } from '#imports';

export default defineEventHandler(async event => {
// The tunnel variant checks that the managed tunnel answers before an auth middleware like this one.
if (process.env.E2E_TEST_TUNNEL && event.method === 'POST' && getHeader(event, 'x-auth') !== 'ok') {
throw createError({ statusCode: 401, statusMessage: 'blocked by user auth' });
}

// Check if we should throw an error
const query = getQuery(event);
if (query.throwError === 'true') {
Expand Down
Loading
Loading