diff --git a/dev-packages/e2e-tests/README.md b/dev-packages/e2e-tests/README.md index 3158ef3f4cff..34acd4ec227b 100644 --- a/dev-packages/e2e-tests/README.md +++ b/dev-packages/e2e-tests/README.md @@ -190,7 +190,9 @@ is the reference setup. `deno run -A --preload=@sentry/deno/import --preload=./instrument.deno.mjs ./node_modules/@react-router/serve/bin.cjs ./build/server/index.js`. The app's `deno.json` maps `@sentry/deno/import` to `node_modules`, because the e2e dependencies are `file:` tarballs that `npm:@sentry/deno/import` does not resolve. `nuxt-4` starts the Nitro output with no preload: - `bun .output/server/index.mjs` and `deno run -A .output/server/index.mjs`. + `bun .output/server/index.mjs` and `deno run -A .output/server/index.mjs`. `express-5` builds CommonJS for Node, so + Deno runs its TypeScript sources (`src/main.ts`), and `deno.json` turns on `sloppy-imports` for the relative imports + without a file extension. - **Cloudflare**: the app has the Cloudflare dependencies installed all the time. The Cloudflare build has its own `vite.cloudflare.config.ts` with `@cloudflare/vite-plugin` and `sentryCloudflareVitePlugin` from `@sentry/cloudflare/vite`, which the runner uses in place of `vite.config.ts` (see runtime-specific files). List the @@ -199,9 +201,10 @@ is the reference setup. separate file (for example `workers/app.ts`) and exports a plain handler: the Sentry plugin wraps it with `withSentry` and reads the init options from `instrument.server.ts` next to the entry. The start command runs `wrangler dev` on the build output. Code at module scope must not do I/O (for example open a database connection), - because workerd does not allow it. `nextjs-16` has no Vite build: its Cloudflare variant builds with - `opennextjs-cloudflare build --config wrangler.opennext.jsonc` and wraps the generated Worker in `worker.ts` with - `withSentry` from `@sentry/nextjs/cloudflare`. + because workerd does not allow it. A socket also works only in the request that opened it, so `express-5` opens its + MySQL connection in the request. In an app without `"type": "module"`, name the config `vite.config.mts`. `nextjs-16` + has no Vite build: its Cloudflare variant builds with `opennextjs-cloudflare build --config wrangler.opennext.jsonc` + and wraps the generated Worker in `worker.ts` with `withSentry` from `@sentry/nextjs/cloudflare`. - **Cloudflare in `vite dev`**: to run the Worker in `vite dev` (for example the dev tests of the `hono-4` Cloudflare variant), start it with `CLOUDFLARE_INCLUDE_PROCESS_ENV=true vite dev`. The runner gives `E2E_TEST_DSN` to the app only as a process env var. `wrangler dev` adds it to the Worker `env` with `--var "E2E_TEST_DSN:$E2E_TEST_DSN"`, but @@ -221,9 +224,10 @@ is the reference setup. - **Bun**: under `bun run` before Bun 1.4.6 the SDK cannot inject diagnostics channels into packages that stay outside the build (for example Express behind `react-router-serve`), so those produce no spans on Bun. Where a test depends on them, branch 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` does. 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. + `@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. ```json "sentryTest": { diff --git a/dev-packages/e2e-tests/test-applications/express-5/.gitignore b/dev-packages/e2e-tests/test-applications/express-5/.gitignore new file mode 100644 index 000000000000..4f6299fec0b1 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/express-5/.gitignore @@ -0,0 +1,4 @@ +dist +dist-bun +dist-cloudflare +.wrangler diff --git a/dev-packages/e2e-tests/test-applications/express-5/bun-build.mjs b/dev-packages/e2e-tests/test-applications/express-5/bun-build.mjs new file mode 100644 index 000000000000..4a4363f2a7d6 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/express-5/bun-build.mjs @@ -0,0 +1,11 @@ +// Bundles the app with `@sentry/bun/plugin`. Under `bun run` the SDK cannot inject diagnostics channels into +// packages, so only a bundled app gets the Express and MySQL spans. +import { sentryBunPlugin } from '@sentry/bun/plugin'; +import { join } from 'node:path'; + +await Bun.build({ + entrypoints: [join(import.meta.dir, 'src/main.ts')], + target: 'bun', + outdir: join(import.meta.dir, 'dist-bun'), + plugins: [sentryBunPlugin({ telemetry: false })], +}); diff --git a/dev-packages/e2e-tests/test-applications/express-5/deno.json b/dev-packages/e2e-tests/test-applications/express-5/deno.json new file mode 100644 index 000000000000..afdc876f8771 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/express-5/deno.json @@ -0,0 +1,7 @@ +{ + "imports": { + "@sentry/deno/import": "./node_modules/@sentry/deno/build/import.mjs" + }, + "nodeModulesDir": "manual", + "unstable": ["sloppy-imports"] +} diff --git a/dev-packages/e2e-tests/test-applications/node-express-v5/docker-compose.yml b/dev-packages/e2e-tests/test-applications/express-5/docker-compose.yml similarity index 90% rename from dev-packages/e2e-tests/test-applications/node-express-v5/docker-compose.yml rename to dev-packages/e2e-tests/test-applications/express-5/docker-compose.yml index 54b0c0f85449..ddaa1872db45 100644 --- a/dev-packages/e2e-tests/test-applications/node-express-v5/docker-compose.yml +++ b/dev-packages/e2e-tests/test-applications/express-5/docker-compose.yml @@ -2,7 +2,7 @@ services: db: image: mysql:8.0 restart: always - container_name: e2e-tests-node-express-v5-mysql + container_name: e2e-tests-express-5-mysql # The `mysql` 2.x driver doesn't speak MySQL 8's default # `caching_sha2_password` auth, so force the legacy plugin. command: ['--default-authentication-plugin=mysql_native_password'] diff --git a/dev-packages/e2e-tests/test-applications/node-express-v5/global-setup.mjs b/dev-packages/e2e-tests/test-applications/express-5/global-setup.mjs similarity index 100% rename from dev-packages/e2e-tests/test-applications/node-express-v5/global-setup.mjs rename to dev-packages/e2e-tests/test-applications/express-5/global-setup.mjs diff --git a/dev-packages/e2e-tests/test-applications/node-express-v5/global-teardown.mjs b/dev-packages/e2e-tests/test-applications/express-5/global-teardown.mjs similarity index 100% rename from dev-packages/e2e-tests/test-applications/node-express-v5/global-teardown.mjs rename to dev-packages/e2e-tests/test-applications/express-5/global-teardown.mjs diff --git a/dev-packages/e2e-tests/test-applications/express-5/package.json b/dev-packages/e2e-tests/test-applications/express-5/package.json new file mode 100644 index 000000000000..8cef4a716563 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/express-5/package.json @@ -0,0 +1,59 @@ +{ + "name": "express-5", + "version": "1.0.0", + "private": true, + "scripts": { + "build": "tsc", + "start": "node dist/main.js", + "start:bun": "bun dist-bun/main.js", + "start:deno": "deno run -A --preload=@sentry/deno/import --preload=./src/instrument.ts src/main.ts", + "start:cloudflare": "wrangler dev --config ./dist-cloudflare/express_5/wrangler.json --port 3030", + "test": "playwright test", + "clean": "npx rimraf node_modules pnpm-lock.yaml", + "test:build": "pnpm install && pnpm build", + "test:build:bun": "pnpm install && pnpm build && bun ./bun-build.mjs", + "test:build:cloudflare": "pnpm install && pnpm build && vite build", + "test:assert": "pnpm test" + }, + "dependencies": { + "@modelcontextprotocol/sdk": "^1.26.0", + "@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/node": "file:../../packed/sentry-node-packed.tgz", + "@trpc/server": "11.8.1", + "@trpc/client": "11.8.1", + "@types/express": "^4.17.21", + "@types/node": "^18.19.1", + "express": "^5.1.0", + "mysql": "^2.18.1", + "typescript": "~5.7.2", + "zod": "^4.6.6" + }, + "devDependencies": { + "@cloudflare/vite-plugin": "^1.47.0", + "@playwright/test": "1.64.1", + "@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz", + "@sentry/core": "file:../../packed/sentry-core-packed.tgz", + "vite": "^8.1.5", + "wrangler": "^4.120.0" + }, + "sentryTest": { + "optionalVariants": [ + { + "runtime": "bun", + "build-command": "pnpm test:build:bun", + "label": "express-5 (bun)" + }, + { + "runtime": "deno", + "label": "express-5 (deno)" + }, + { + "runtime": "cloudflare", + "build-command": "pnpm test:build:cloudflare", + "label": "express-5 (cloudflare)" + } + ] + } +} diff --git a/dev-packages/e2e-tests/test-applications/express-5/playwright.config.mjs b/dev-packages/e2e-tests/test-applications/express-5/playwright.config.mjs new file mode 100644 index 000000000000..4c891f756a2c --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/express-5/playwright.config.mjs @@ -0,0 +1,18 @@ +import { getPlaywrightConfig, getRuntime } from '@sentry-internal/test-utils'; + +const startCommands = { + node: 'pnpm start', + bun: 'pnpm start:bun', + deno: 'pnpm start:deno', + cloudflare: 'pnpm start:cloudflare', +}; + +const config = getPlaywrightConfig({ + startCommand: startCommands[getRuntime()], +}); + +export default { + ...config, + globalSetup: './global-setup.mjs', + globalTeardown: './global-teardown.mjs', +}; diff --git a/dev-packages/e2e-tests/test-applications/node-express-v5/pnpm-workspace.yaml b/dev-packages/e2e-tests/test-applications/express-5/pnpm-workspace.yaml similarity index 55% rename from dev-packages/e2e-tests/test-applications/node-express-v5/pnpm-workspace.yaml rename to dev-packages/e2e-tests/test-applications/express-5/pnpm-workspace.yaml index 3db4c8f6a559..e8282517f17d 100644 --- a/dev-packages/e2e-tests/test-applications/node-express-v5/pnpm-workspace.yaml +++ b/dev-packages/e2e-tests/test-applications/express-5/pnpm-workspace.yaml @@ -1,3 +1,6 @@ +allowBuilds: + esbuild: true + workerd: true minimumReleaseAge: 0 overrides: '@types/qs': '6.9.17' diff --git a/dev-packages/e2e-tests/test-applications/node-express-v5/src/app.ts b/dev-packages/e2e-tests/test-applications/express-5/src/app.ts similarity index 81% rename from dev-packages/e2e-tests/test-applications/node-express-v5/src/app.ts rename to dev-packages/e2e-tests/test-applications/express-5/src/app.ts index d2b7f600040e..f78c2f30c0e4 100644 --- a/dev-packages/e2e-tests/test-applications/node-express-v5/src/app.ts +++ b/dev-packages/e2e-tests/test-applications/express-5/src/app.ts @@ -1,21 +1,3 @@ -import * as Sentry from '@sentry/node'; - -declare global { - namespace globalThis { - var transactionIds: string[]; - } -} - -Sentry.init({ - environment: 'qa', // dynamic sampling bias to keep transactions - dsn: process.env.E2E_TEST_DSN, - includeLocalVariables: true, - debug: !!process.env.DEBUG, - tunnel: `http://localhost:3031/`, // proxy server - tracesSampleRate: 1, - integrations: [Sentry.nodeRuntimeMetricsIntegration({ collectionIntervalMs: 1_000 })], -}); - import { TRPCError, initTRPC } from '@trpc/server'; import * as trpcExpress from '@trpc/server/adapters/express'; import express from 'express'; @@ -23,14 +5,15 @@ import express from 'express'; import mysql from 'mysql'; import { z } from 'zod'; import { mcpRouter } from './mcp'; +import * as Sentry from './sentry'; -const connection = mysql.createConnection({ - user: 'root', - password: 'docker', -}); +declare global { + namespace globalThis { + var transactionIds: string[]; + } +} -const app = express(); -const port = 3030; +export const app = express(); app.use(mcpRouter); @@ -60,8 +43,15 @@ app.get('/test-param/:param', function (req, res) { }); app.get('/test-mysql', function (req, res) { + // One connection per request, because on Cloudflare a socket only works in the request that opened it. + const connection = mysql.createConnection({ + user: 'root', + password: 'docker', + }); + connection.query('SELECT 1 + 1 AS solution', function () { connection.query('SELECT NOW()', ['1', '2'], () => { + connection.end(); res.send({ status: 'ok' }); }); }); @@ -103,6 +93,20 @@ app.get('/test-local-variables-caught', function (req, res) { res.send({ exceptionId, randomVariableToRecord }); }); +app.get('/test-isolation/:id', async function (req, res) { + Sentry.setTag('isolation-id', req.params.id); + // Lets the concurrent requests of the isolation test overlap. + await new Promise(resolve => setTimeout(resolve, 200)); + Sentry.captureException(new Error(`Isolated error ${req.params.id}`)); + res.send({}); +}); + +// The test runs a server on port 3040 that records the headers of the request. +app.get('/test-outgoing-fetch', async function (_req, res) { + const response = await fetch('http://localhost:3040/outgoing'); + res.send({ status: response.status }); +}); + // @ts-ignore app.use(function onError(err, req, res, next) { // The error id is attached to `res.sentry` to be returned @@ -111,10 +115,6 @@ app.use(function onError(err, req, res, next) { res.end(res.sentry + '\n'); }); -app.listen(port, () => { - console.log(`Example app listening on port ${port}`); -}); - Sentry.addEventProcessor(event => { global.transactionIds = global.transactionIds || []; diff --git a/dev-packages/e2e-tests/test-applications/express-5/src/instrument.bun.ts b/dev-packages/e2e-tests/test-applications/express-5/src/instrument.bun.ts new file mode 100644 index 000000000000..1e933d686aa1 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/express-5/src/instrument.bun.ts @@ -0,0 +1,9 @@ +import * as Sentry from '@sentry/bun'; + +Sentry.init({ + environment: 'qa', // dynamic sampling bias to keep transactions + dsn: process.env.E2E_TEST_DSN, + debug: !!process.env.DEBUG, + tunnel: `http://localhost:3031/`, // proxy server + tracesSampleRate: 1, +}); diff --git a/dev-packages/e2e-tests/test-applications/express-5/src/instrument.deno.ts b/dev-packages/e2e-tests/test-applications/express-5/src/instrument.deno.ts new file mode 100644 index 000000000000..dee01f30487d --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/express-5/src/instrument.deno.ts @@ -0,0 +1,9 @@ +import * as Sentry from '@sentry/deno'; + +Sentry.init({ + environment: 'qa', // dynamic sampling bias to keep transactions + dsn: process.env.E2E_TEST_DSN, + debug: !!process.env.DEBUG, + tunnel: `http://localhost:3031/`, // proxy server + tracesSampleRate: 1, +}); diff --git a/dev-packages/e2e-tests/test-applications/express-5/src/instrument.ts b/dev-packages/e2e-tests/test-applications/express-5/src/instrument.ts new file mode 100644 index 000000000000..57c99c08250d --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/express-5/src/instrument.ts @@ -0,0 +1,11 @@ +import * as Sentry from '@sentry/node'; + +Sentry.init({ + environment: 'qa', // dynamic sampling bias to keep transactions + dsn: process.env.E2E_TEST_DSN, + includeLocalVariables: true, + debug: !!process.env.DEBUG, + tunnel: `http://localhost:3031/`, // proxy server + tracesSampleRate: 1, + integrations: [Sentry.nodeRuntimeMetricsIntegration({ collectionIntervalMs: 1_000 })], +}); diff --git a/dev-packages/e2e-tests/test-applications/express-5/src/main.ts b/dev-packages/e2e-tests/test-applications/express-5/src/main.ts new file mode 100644 index 000000000000..a137bd6c51ba --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/express-5/src/main.ts @@ -0,0 +1,9 @@ +import './instrument'; + +import { app } from './app'; + +const port = 3030; + +app.listen(port, () => { + console.log(`Example app listening on port ${port}`); +}); diff --git a/dev-packages/e2e-tests/test-applications/node-express-v5/src/mcp.ts b/dev-packages/e2e-tests/test-applications/express-5/src/mcp.ts similarity index 99% rename from dev-packages/e2e-tests/test-applications/node-express-v5/src/mcp.ts rename to dev-packages/e2e-tests/test-applications/express-5/src/mcp.ts index 09472a9288be..a9beb310f386 100644 --- a/dev-packages/e2e-tests/test-applications/node-express-v5/src/mcp.ts +++ b/dev-packages/e2e-tests/test-applications/express-5/src/mcp.ts @@ -4,7 +4,7 @@ import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mc import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js'; import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js'; import { z } from 'zod'; -import { wrapMcpServerWithSentry } from '@sentry/node'; +import { wrapMcpServerWithSentry } from './sentry'; // Helper to check if request is an initialize request (compatible with all MCP SDK versions) function isInitializeRequest(body: unknown): boolean { diff --git a/dev-packages/e2e-tests/test-applications/express-5/src/sentry.bun.ts b/dev-packages/e2e-tests/test-applications/express-5/src/sentry.bun.ts new file mode 100644 index 000000000000..7bf1576974c3 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/express-5/src/sentry.bun.ts @@ -0,0 +1 @@ +export * from '@sentry/bun'; diff --git a/dev-packages/e2e-tests/test-applications/express-5/src/sentry.cloudflare.ts b/dev-packages/e2e-tests/test-applications/express-5/src/sentry.cloudflare.ts new file mode 100644 index 000000000000..1f7059531cd9 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/express-5/src/sentry.cloudflare.ts @@ -0,0 +1 @@ +export * from '@sentry/cloudflare'; diff --git a/dev-packages/e2e-tests/test-applications/express-5/src/sentry.deno.ts b/dev-packages/e2e-tests/test-applications/express-5/src/sentry.deno.ts new file mode 100644 index 000000000000..412874a768aa --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/express-5/src/sentry.deno.ts @@ -0,0 +1 @@ +export * from '@sentry/deno'; diff --git a/dev-packages/e2e-tests/test-applications/express-5/src/sentry.ts b/dev-packages/e2e-tests/test-applications/express-5/src/sentry.ts new file mode 100644 index 000000000000..fb7328c77640 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/express-5/src/sentry.ts @@ -0,0 +1,2 @@ +// The app imports the Sentry API from this file. Each other runtime has a `sentry..ts` with its own SDK. +export * from '@sentry/node'; diff --git a/dev-packages/e2e-tests/test-applications/node-express-v5/start-event-proxy.mjs b/dev-packages/e2e-tests/test-applications/express-5/start-event-proxy.mjs similarity index 74% rename from dev-packages/e2e-tests/test-applications/node-express-v5/start-event-proxy.mjs rename to dev-packages/e2e-tests/test-applications/express-5/start-event-proxy.mjs index 9bc400437556..a57b316e6178 100644 --- a/dev-packages/e2e-tests/test-applications/node-express-v5/start-event-proxy.mjs +++ b/dev-packages/e2e-tests/test-applications/express-5/start-event-proxy.mjs @@ -2,5 +2,5 @@ import { startEventProxyServer } from '@sentry-internal/test-utils'; startEventProxyServer({ port: 3031, - proxyServerName: 'node-express-v5', + proxyServerName: 'express-5', }); diff --git a/dev-packages/e2e-tests/test-applications/express-5/tests/constants.ts b/dev-packages/e2e-tests/test-applications/express-5/tests/constants.ts new file mode 100644 index 000000000000..a7199ff7d5ff --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/express-5/tests/constants.ts @@ -0,0 +1,3 @@ +import { getRuntime } from '@sentry-internal/test-utils'; + +export const RUNTIME = getRuntime(); diff --git a/dev-packages/e2e-tests/test-applications/node-express-v5/tests/errors.test.ts b/dev-packages/e2e-tests/test-applications/express-5/tests/errors.test.ts similarity index 88% rename from dev-packages/e2e-tests/test-applications/node-express-v5/tests/errors.test.ts rename to dev-packages/e2e-tests/test-applications/express-5/tests/errors.test.ts index 2bad35b574d1..322d962ce6d2 100644 --- a/dev-packages/e2e-tests/test-applications/node-express-v5/tests/errors.test.ts +++ b/dev-packages/e2e-tests/test-applications/express-5/tests/errors.test.ts @@ -1,12 +1,13 @@ import { expect, test } from '@playwright/test'; import { waitForError, collectStreamedSpansUntilSegment } from '@sentry-internal/test-utils'; +import { RUNTIME } from './constants'; test('Sends correct error event', async ({ baseURL }) => { - const errorEventPromise = waitForError('node-express-v5', event => { + const errorEventPromise = waitForError('express-5', event => { return !event.type && event.exception?.values?.[0]?.value === 'This is an exception with id 123'; }); - const segmentEventPromise = collectStreamedSpansUntilSegment('node-express-v5', 'GET /test-exception/:id'); + const segmentEventPromise = collectStreamedSpansUntilSegment('express-5', 'GET /test-exception/:id'); await fetch(`${baseURL}/test-exception/123`); @@ -49,7 +50,12 @@ test('Sends correct error event', async ({ baseURL }) => { }); test('Should record caught exceptions with local variable', async ({ baseURL }) => { - const errorEventPromise = waitForError('node-express-v5', event => { + test.skip( + RUNTIME !== 'node', + '`includeLocalVariables` reads the variables with `node:inspector`, which works on Node only.', + ); + + const errorEventPromise = waitForError('express-5', event => { return event.transaction === 'GET /test-local-variables-caught'; }); diff --git a/dev-packages/e2e-tests/test-applications/node-express-v5/tests/logs.test.ts b/dev-packages/e2e-tests/test-applications/express-5/tests/logs.test.ts similarity index 87% rename from dev-packages/e2e-tests/test-applications/node-express-v5/tests/logs.test.ts rename to dev-packages/e2e-tests/test-applications/express-5/tests/logs.test.ts index 34bce0a0b978..e91e1174ad3b 100644 --- a/dev-packages/e2e-tests/test-applications/node-express-v5/tests/logs.test.ts +++ b/dev-packages/e2e-tests/test-applications/express-5/tests/logs.test.ts @@ -3,7 +3,7 @@ import { waitForEnvelopeItem } from '@sentry-internal/test-utils'; import type { SerializedLogContainer } from '@sentry/core'; test('should send logs', async ({ baseURL }) => { - const logEnvelopePromise = waitForEnvelopeItem('node-express-v5', envelope => { + const logEnvelopePromise = waitForEnvelopeItem('express-5', envelope => { return envelope[0].type === 'log' && (envelope[1] as SerializedLogContainer).items[0]?.level === 'debug'; }); diff --git a/dev-packages/e2e-tests/test-applications/node-express-v5/tests/mcp.test.ts b/dev-packages/e2e-tests/test-applications/express-5/tests/mcp.test.ts similarity index 94% rename from dev-packages/e2e-tests/test-applications/node-express-v5/tests/mcp.test.ts rename to dev-packages/e2e-tests/test-applications/express-5/tests/mcp.test.ts index 65efec350587..3ca46435ffa9 100644 --- a/dev-packages/e2e-tests/test-applications/node-express-v5/tests/mcp.test.ts +++ b/dev-packages/e2e-tests/test-applications/express-5/tests/mcp.test.ts @@ -3,8 +3,14 @@ import { waitForStreamedSpan, getSpanOp } from '@sentry-internal/test-utils'; import { Client } from '@modelcontextprotocol/sdk/client/index.js'; import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js'; import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'; +import { RUNTIME } from './constants'; test('Should record spans for mcp handlers', async ({ baseURL }) => { + test.skip( + RUNTIME === 'cloudflare', + 'The SSE transport answers `POST /messages` on the open response of `GET /sse`. workerd cancels a write to the response of another request.', + ); + const transport = new SSEClientTransport(new URL(`${baseURL}/sse`)); const client = new Client({ @@ -13,7 +19,7 @@ test('Should record spans for mcp handlers', async ({ baseURL }) => { }); const initializeSegmentPromise = waitForStreamedSpan( - 'node-express-v5', + 'express-5', segment => segment.is_segment && segment.name === 'initialize', ); @@ -30,11 +36,11 @@ test('Should record spans for mcp handlers', async ({ baseURL }) => { await test.step('tool handler', async () => { const postSegmentPromise = waitForStreamedSpan( - 'node-express-v5', + 'express-5', segment => segment.is_segment && segment.name === 'POST /messages', ); const toolSegmentPromise = waitForStreamedSpan( - 'node-express-v5', + 'express-5', segment => segment.is_segment && segment.name === 'tools/call echo', ); @@ -65,11 +71,11 @@ test('Should record spans for mcp handlers', async ({ baseURL }) => { await test.step('registerTool handler', async () => { const postSegmentPromise = waitForStreamedSpan( - 'node-express-v5', + 'express-5', segment => segment.is_segment && segment.name === 'POST /messages', ); const toolSegmentPromise = waitForStreamedSpan( - 'node-express-v5', + 'express-5', segment => segment.is_segment && segment.name === 'tools/call echo-register', ); @@ -99,11 +105,11 @@ test('Should record spans for mcp handlers', async ({ baseURL }) => { await test.step('resource handler', async () => { const postSegmentPromise = waitForStreamedSpan( - 'node-express-v5', + 'express-5', segment => segment.is_segment && segment.name === 'POST /messages', ); const resourceSegmentPromise = waitForStreamedSpan( - 'node-express-v5', + 'express-5', segment => segment.is_segment && segment.name === 'resources/read', ); @@ -126,11 +132,11 @@ test('Should record spans for mcp handlers', async ({ baseURL }) => { await test.step('prompt handler', async () => { const postSegmentPromise = waitForStreamedSpan( - 'node-express-v5', + 'express-5', segment => segment.is_segment && segment.name === 'POST /messages', ); const promptSegmentPromise = waitForStreamedSpan( - 'node-express-v5', + 'express-5', segment => segment.is_segment && segment.name === 'prompts/get echo', ); @@ -164,7 +170,7 @@ test('Should record spans for mcp handlers', async ({ baseURL }) => { await test.step('error tool sets span status to error', async () => { const toolSegmentPromise = waitForStreamedSpan( - 'node-express-v5', + 'express-5', segment => segment.is_segment && segment.name === 'tools/call always-error', ); @@ -201,7 +207,7 @@ test('Should record spans for streamable HTTP transport (wrapper transport patte }); const initializeSegmentPromise = waitForStreamedSpan( - 'node-express-v5', + 'express-5', segment => segment.is_segment && segment.name === 'initialize' && @@ -224,7 +230,7 @@ test('Should record spans for streamable HTTP transport (wrapper transport patte await test.step('tool handler (tests wrapper transport correlation)', async () => { // This is the critical test - without the sessionId fix, the span would not be completed // because onmessage and send see different transport instances (wrapper vs inner) - const toolSegmentPromise = waitForStreamedSpan('node-express-v5', segment => { + const toolSegmentPromise = waitForStreamedSpan('express-5', segment => { if (!segment.is_segment) return false; const transport = segment.attributes?.['mcp.transport']?.value as string | undefined; return segment.name === 'tools/call echo' && !!transport?.includes('StreamableHTTPServerTransport'); @@ -256,7 +262,7 @@ test('Should record spans for streamable HTTP transport (wrapper transport patte }); await test.step('resource handler', async () => { - const resourceSegmentPromise = waitForStreamedSpan('node-express-v5', segment => { + const resourceSegmentPromise = waitForStreamedSpan('express-5', segment => { if (!segment.is_segment) return false; const transport = segment.attributes?.['mcp.transport']?.value as string | undefined; return segment.name === 'resources/read' && !!transport?.includes('StreamableHTTPServerTransport'); @@ -277,7 +283,7 @@ test('Should record spans for streamable HTTP transport (wrapper transport patte }); await test.step('prompt handler', async () => { - const promptSegmentPromise = waitForStreamedSpan('node-express-v5', segment => { + const promptSegmentPromise = waitForStreamedSpan('express-5', segment => { if (!segment.is_segment) return false; const transport = segment.attributes?.['mcp.transport']?.value as string | undefined; return segment.name === 'prompts/get echo' && !!transport?.includes('StreamableHTTPServerTransport'); diff --git a/dev-packages/e2e-tests/test-applications/node-express-v5/tests/mysql.test.ts b/dev-packages/e2e-tests/test-applications/express-5/tests/mysql.test.ts similarity index 98% rename from dev-packages/e2e-tests/test-applications/node-express-v5/tests/mysql.test.ts rename to dev-packages/e2e-tests/test-applications/express-5/tests/mysql.test.ts index 90a20f331ac7..0f288a8e9267 100644 --- a/dev-packages/e2e-tests/test-applications/node-express-v5/tests/mysql.test.ts +++ b/dev-packages/e2e-tests/test-applications/express-5/tests/mysql.test.ts @@ -3,7 +3,7 @@ import { getSpanOp, collectStreamedSpansUntilSegment } from '@sentry-internal/te test('Instruments MySQL via Orchestrion', async ({ baseURL }) => { const segmentEventPromise = collectStreamedSpansUntilSegment( - 'node-express-v5', + 'express-5', segment => getSpanOp(segment) === 'http.server' && segment.name === 'GET /test-mysql', ); diff --git a/dev-packages/e2e-tests/test-applications/node-express-v5/tests/node-runtime-metrics.test.ts b/dev-packages/e2e-tests/test-applications/express-5/tests/node-runtime-metrics.test.ts similarity index 86% rename from dev-packages/e2e-tests/test-applications/node-express-v5/tests/node-runtime-metrics.test.ts rename to dev-packages/e2e-tests/test-applications/express-5/tests/node-runtime-metrics.test.ts index e8e0aef3be17..5d29eea7f15a 100644 --- a/dev-packages/e2e-tests/test-applications/node-express-v5/tests/node-runtime-metrics.test.ts +++ b/dev-packages/e2e-tests/test-applications/express-5/tests/node-runtime-metrics.test.ts @@ -1,5 +1,8 @@ import { expect, test } from '@playwright/test'; import { waitForMetric } from '@sentry-internal/test-utils'; +import { RUNTIME } from './constants'; + +test.skip(RUNTIME !== 'node', '`nodeRuntimeMetricsIntegration` is a Node-only integration.'); const EXPECTED_ATTRIBUTES = { 'sentry.environment': { value: 'qa', type: 'string' }, @@ -9,15 +12,15 @@ const EXPECTED_ATTRIBUTES = { }; test('Should emit node runtime memory metrics', async ({ baseURL }) => { - const rssPromise = waitForMetric('node-express-v5', metric => { + const rssPromise = waitForMetric('express-5', metric => { return metric.name === 'node.runtime.mem.rss'; }); - const heapUsedPromise = waitForMetric('node-express-v5', metric => { + const heapUsedPromise = waitForMetric('express-5', metric => { return metric.name === 'node.runtime.mem.heap_used'; }); - const heapTotalPromise = waitForMetric('node-express-v5', metric => { + const heapTotalPromise = waitForMetric('express-5', metric => { return metric.name === 'node.runtime.mem.heap_total'; }); @@ -60,7 +63,7 @@ test('Should emit node runtime memory metrics', async ({ baseURL }) => { }); test('Should emit node runtime CPU utilization metric', async ({ baseURL }) => { - const cpuUtilPromise = waitForMetric('node-express-v5', metric => { + const cpuUtilPromise = waitForMetric('express-5', metric => { return metric.name === 'node.runtime.cpu.utilization'; }); @@ -79,15 +82,15 @@ test('Should emit node runtime CPU utilization metric', async ({ baseURL }) => { }); test('Should emit node runtime event loop metrics', async ({ baseURL }) => { - const elDelayP50Promise = waitForMetric('node-express-v5', metric => { + const elDelayP50Promise = waitForMetric('express-5', metric => { return metric.name === 'node.runtime.event_loop.delay.p50'; }); - const elDelayP99Promise = waitForMetric('node-express-v5', metric => { + const elDelayP99Promise = waitForMetric('express-5', metric => { return metric.name === 'node.runtime.event_loop.delay.p99'; }); - const elUtilPromise = waitForMetric('node-express-v5', metric => { + const elUtilPromise = waitForMetric('express-5', metric => { return metric.name === 'node.runtime.event_loop.utilization'; }); @@ -128,7 +131,7 @@ test('Should emit node runtime event loop metrics', async ({ baseURL }) => { }); test('Should emit node runtime uptime counter', async ({ baseURL }) => { - const uptimePromise = waitForMetric('node-express-v5', metric => { + const uptimePromise = waitForMetric('express-5', metric => { return metric.name === 'node.runtime.process.uptime'; }); diff --git a/dev-packages/e2e-tests/test-applications/express-5/tests/request.test.ts b/dev-packages/e2e-tests/test-applications/express-5/tests/request.test.ts new file mode 100644 index 000000000000..386280dabbcd --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/express-5/tests/request.test.ts @@ -0,0 +1,88 @@ +import { expect, test } from '@playwright/test'; +import { collectStreamedSpansUntilSegment, getSpanOp, waitForError } from '@sentry-internal/test-utils'; +import type { IncomingHttpHeaders } from 'node:http'; +import { createServer } from 'node:http'; + +const TRACE_ID = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'; +const PARENT_SPAN_ID = 'bbbbbbbbbbbbbbbb'; + +test('Names the request span after the parameterized route', async ({ baseURL }) => { + const spansPromise = collectStreamedSpansUntilSegment('express-5', 'GET /test-param/:param'); + + const response = await fetch(`${baseURL}/test-param/123`); + expect(await response.json()).toEqual({ paramWas: '123' }); + + const segmentSpan = (await spansPromise).find(span => span.is_segment)!; + expect(segmentSpan.attributes).toMatchObject({ + 'sentry.op': { type: 'string', value: 'http.server' }, + 'sentry.segment.name.source': { type: 'string', value: 'route' }, + 'http.route': { type: 'string', value: '/test-param/:param' }, + 'url.path': { type: 'string', value: '/test-param/123' }, + }); +}); + +test('Keeps the scope data of concurrent requests apart', async ({ baseURL }) => { + const ids = ['1', '2', '3']; + const errorPromises = ids.map(id => + waitForError('express-5', event => event.exception?.values?.[0]?.value === `Isolated error ${id}`), + ); + + await Promise.all(ids.map(id => fetch(`${baseURL}/test-isolation/${id}`))); + + const errors = await Promise.all(errorPromises); + errors.forEach((error, index) => { + expect(error.tags?.['isolation-id']).toBe(ids[index]); + expect(error.transaction).toBe('GET /test-isolation/:id'); + }); + + const traceIds = errors.map(error => error.contexts?.trace?.trace_id); + expect(new Set(traceIds).size).toBe(ids.length); +}); + +test('Continues the trace of an incoming request', async ({ baseURL }) => { + const spansPromise = collectStreamedSpansUntilSegment( + 'express-5', + span => span.name === 'GET /test-param/:param' && span.trace_id === TRACE_ID, + ); + + await fetch(`${baseURL}/test-param/continued`, { + headers: { + 'sentry-trace': `${TRACE_ID}-${PARENT_SPAN_ID}-1`, + baggage: `sentry-trace_id=${TRACE_ID},sentry-environment=qa,sentry-public_key=public,sentry-sampled=true`, + }, + }); + + const segmentSpan = (await spansPromise).find(span => span.is_segment)!; + expect(segmentSpan.trace_id).toBe(TRACE_ID); + expect(segmentSpan.parent_span_id).toBe(PARENT_SPAN_ID); +}); + +test('Propagates the trace to an outgoing fetch request', async ({ baseURL }) => { + let receivedHeaders: IncomingHttpHeaders | undefined; + const server = createServer((req, res) => { + receivedHeaders = req.headers; + res.end('ok'); + }); + await new Promise(resolve => server.listen(3040, resolve)); + + try { + const spansPromise = collectStreamedSpansUntilSegment('express-5', 'GET /test-outgoing-fetch'); + + const response = await fetch(`${baseURL}/test-outgoing-fetch`); + expect(await response.json()).toEqual({ status: 200 }); + + const spans = await spansPromise; + const segmentSpan = spans.find(span => span.is_segment)!; + const fetchSpan = spans.find(span => getSpanOp(span) === 'http.client'); + + expect(fetchSpan).toBeDefined(); + expect(fetchSpan!.trace_id).toBe(segmentSpan.trace_id); + expect(fetchSpan!.attributes['http.request.method']).toEqual({ type: 'string', value: 'GET' }); + + expect(receivedHeaders?.['sentry-trace']).toBe(`${segmentSpan.trace_id}-${fetchSpan!.span_id}-1`); + expect(receivedHeaders?.baggage).toContain(`sentry-trace_id=${segmentSpan.trace_id}`); + expect(receivedHeaders?.baggage).toContain('sentry-environment=qa'); + } finally { + await new Promise(resolve => server.close(resolve)); + } +}); diff --git a/dev-packages/e2e-tests/test-applications/node-express-v5/tests/spans.test.ts b/dev-packages/e2e-tests/test-applications/express-5/tests/spans.test.ts similarity index 74% rename from dev-packages/e2e-tests/test-applications/node-express-v5/tests/spans.test.ts rename to dev-packages/e2e-tests/test-applications/express-5/tests/spans.test.ts index 926328c3f8e5..cd19f04e09e3 100644 --- a/dev-packages/e2e-tests/test-applications/node-express-v5/tests/spans.test.ts +++ b/dev-packages/e2e-tests/test-applications/express-5/tests/spans.test.ts @@ -1,9 +1,10 @@ import { expect, test } from '@playwright/test'; import { waitForStreamedSpan, getSpanOp, collectStreamedSpansUntilSegment } from '@sentry-internal/test-utils'; +import { RUNTIME } from './constants'; test('Sends an API route span', async ({ baseURL }) => { const pageloadSegmentEventPromise = collectStreamedSpansUntilSegment( - 'node-express-v5', + 'express-5', segment => getSpanOp(segment) === 'http.server' && segment.name === 'GET /test-transaction', ); @@ -21,10 +22,8 @@ test('Sends an API route span', async ({ baseURL }) => { trace_id: expect.stringMatching(/[a-f0-9]{32}/), attributes: expect.objectContaining({ 'sentry.segment.name.source': { value: 'route', type: 'string' }, - 'sentry.origin': { value: 'auto.http.http_server', type: 'string' }, 'sentry.op': { value: 'http.server', type: 'string' }, 'sentry.sample_rate': { value: 1, type: 'integer' }, - 'sentry.kind': { value: 'server', type: 'string' }, 'http.response.status_code': { value: 200, type: 'integer' }, 'url.full': { value: 'http://localhost:3030/test-transaction', type: 'string' }, 'url.path': { value: '/test-transaction', type: 'string' }, @@ -33,24 +32,38 @@ test('Sends an API route span', async ({ baseURL }) => { 'url.scheme': { value: 'http', type: 'string' }, 'user_agent.original': { value: 'node', type: 'string' }, 'client.address': { value: '::1', type: 'string' }, - 'client.port': { value: expect.any(Number), type: 'integer' }, - 'network.transport': { value: 'tcp', type: 'string' }, - 'network.local.address': { value: expect.any(String), type: 'string' }, - 'network.local.port': { value: expect.any(Number), type: 'integer' }, - 'network.peer.address': { value: expect.any(String), type: 'string' }, - 'network.peer.port': { value: expect.any(Number), type: 'integer' }, 'network.protocol.name': { value: 'http', type: 'string' }, 'network.protocol.version': { value: '1.1', type: 'string' }, - 'server.port': { value: 3030, type: 'integer' }, - 'http.response.status_text': { value: 'OK', type: 'string' }, 'http.route': { value: '/test-transaction', type: 'string' }, 'http.request.header.accept': { value: ['*/*'], type: 'array' }, - 'http.request.header.accept-encoding': { value: ['gzip, deflate'], type: 'array' }, 'http.request.header.accept-language': { value: ['*'], type: 'array' }, - 'http.request.header.connection': { value: ['keep-alive'], type: 'array' }, 'http.request.header.host': { value: [expect.any(String)], type: 'array' }, 'http.request.header.sec-fetch-mode': { value: ['cors'], type: 'array' }, 'http.request.header.user-agent': { value: ['node'], type: 'array' }, + 'sentry.kind': { value: 'server', type: 'string' }, + // On Cloudflare, `withSentry` creates the `http.server` span from the worker's `Request`, not from `node:http`. + // Known defect: the span has no `http.response.status_text`. + ...(RUNTIME === 'cloudflare' + ? { + 'sentry.origin': { value: 'auto.http.cloudflare', type: 'string' }, + 'url.port': { value: 3030, type: 'integer' }, + 'http.request.header.accept-encoding': { value: ['br, gzip'], type: 'array' }, + } + : { + 'sentry.origin': { value: 'auto.http.http_server', type: 'string' }, + 'client.port': { value: expect.any(Number), type: 'integer' }, + 'network.transport': { value: 'tcp', type: 'string' }, + 'network.local.address': { value: expect.any(String), type: 'string' }, + 'network.local.port': { value: expect.any(Number), type: 'integer' }, + 'network.peer.address': { value: expect.any(String), type: 'string' }, + 'network.peer.port': { value: expect.any(Number), type: 'integer' }, + 'server.port': { value: 3030, type: 'integer' }, + 'http.request.header.accept-encoding': { value: ['gzip, deflate'], type: 'array' }, + 'http.request.header.connection': { value: ['keep-alive'], type: 'array' }, + // Known defect: Bun's `node:http` leaves `statusMessage` unset when the app does not set it, and the + // SDK does not fall back to the standard reason phrase. + ...(RUNTIME === 'bun' ? {} : { 'http.response.status_text': { value: 'OK', type: 'string' } }), + }), }), }), ); @@ -106,7 +119,7 @@ test('Sends an API route span', async ({ baseURL }) => { test('Sends an API route span for an errored route', async ({ baseURL }) => { const segmentEventPromise = waitForStreamedSpan( - 'node-express-v5', + 'express-5', segment => segment.is_segment && getSpanOp(segment) === 'http.server' && diff --git a/dev-packages/e2e-tests/test-applications/node-express-v5/tests/trpc.test.ts b/dev-packages/e2e-tests/test-applications/express-5/tests/trpc.test.ts similarity index 92% rename from dev-packages/e2e-tests/test-applications/node-express-v5/tests/trpc.test.ts rename to dev-packages/e2e-tests/test-applications/express-5/tests/trpc.test.ts index f2114f1edce4..80f8d4f6cf2f 100644 --- a/dev-packages/e2e-tests/test-applications/node-express-v5/tests/trpc.test.ts +++ b/dev-packages/e2e-tests/test-applications/express-5/tests/trpc.test.ts @@ -4,7 +4,7 @@ import { createTRPCClient, httpBatchLink } from '@trpc/client'; import type { AppRouter } from '../src/app'; test('Should record span for trpc query', async ({ baseURL }) => { - const segmentEventPromise = collectStreamedSpans('node-express-v5', spans => + const segmentEventPromise = collectStreamedSpans('express-5', spans => spans.some( segment => segment.is_segment && @@ -50,7 +50,7 @@ test('Should record span for trpc query', async ({ baseURL }) => { }); test('Should record span for trpc mutation', async ({ baseURL }) => { - const segmentEventPromise = collectStreamedSpans('node-express-v5', spans => + const segmentEventPromise = collectStreamedSpans('express-5', spans => spans.some( segment => segment.is_segment && @@ -96,7 +96,7 @@ test('Should record span for trpc mutation', async ({ baseURL }) => { }); test('Should record span and error for a crashing trpc handler', async ({ baseURL }) => { - const segmentEventPromise = collectStreamedSpans('node-express-v5', spans => + const segmentEventPromise = collectStreamedSpans('express-5', spans => spans.some( segment => segment.is_segment && @@ -105,7 +105,7 @@ test('Should record span and error for a crashing trpc handler', async ({ baseUR ), ); - const errorEventPromise = waitForError('node-express-v5', errorEvent => { + const errorEventPromise = waitForError('express-5', errorEvent => { return !!errorEvent?.exception?.values?.some(exception => exception.value?.includes('I crashed in a trpc handler')); }); @@ -152,7 +152,7 @@ test('Should record span and error for a crashing trpc handler', async ({ baseUR }); test('Should record span and error for a trpc handler that returns a status code', async ({ baseURL }) => { - const segmentEventPromise = collectStreamedSpans('node-express-v5', spans => + const segmentEventPromise = collectStreamedSpans('express-5', spans => spans.some( segment => segment.is_segment && @@ -161,7 +161,7 @@ test('Should record span and error for a trpc handler that returns a status code ), ); - const errorEventPromise = waitForError('node-express-v5', errorEvent => { + const errorEventPromise = waitForError('express-5', errorEvent => { return !!errorEvent?.exception?.values?.some(exception => exception.value?.includes('Bad Request')); }); diff --git a/dev-packages/e2e-tests/test-applications/node-express-v5/tsconfig.json b/dev-packages/e2e-tests/test-applications/express-5/tsconfig.json similarity index 61% rename from dev-packages/e2e-tests/test-applications/node-express-v5/tsconfig.json rename to dev-packages/e2e-tests/test-applications/express-5/tsconfig.json index 0060abd94682..7fdb6965f021 100644 --- a/dev-packages/e2e-tests/test-applications/node-express-v5/tsconfig.json +++ b/dev-packages/e2e-tests/test-applications/express-5/tsconfig.json @@ -7,5 +7,6 @@ "outDir": "dist", "skipLibCheck": true }, - "include": ["src/**/*.ts"] + "include": ["src/**/*.ts"], + "exclude": ["src/**/*.bun.ts", "src/**/*.deno.ts", "src/**/*.cloudflare.ts"] } diff --git a/dev-packages/e2e-tests/test-applications/express-5/vite.config.mts b/dev-packages/e2e-tests/test-applications/express-5/vite.config.mts new file mode 100644 index 000000000000..9b612604467b --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/express-5/vite.config.mts @@ -0,0 +1,9 @@ +import { cloudflare } from '@cloudflare/vite-plugin'; +import { sentryCloudflareVitePlugin } from '@sentry/cloudflare/vite'; +import { defineConfig } from 'vite'; + +// Only the Cloudflare variant builds with Vite. +export default defineConfig({ + build: { outDir: 'dist-cloudflare' }, + plugins: [cloudflare(), sentryCloudflareVitePlugin()], +}); diff --git a/dev-packages/e2e-tests/test-applications/express-5/workers/app.ts b/dev-packages/e2e-tests/test-applications/express-5/workers/app.ts new file mode 100644 index 000000000000..32c75bf94f6a --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/express-5/workers/app.ts @@ -0,0 +1,8 @@ +import { httpServerHandler } from 'cloudflare:node'; +import { app } from '../src/app'; + +const PORT = 3030; + +app.listen(PORT); + +export default httpServerHandler({ port: PORT }); diff --git a/dev-packages/e2e-tests/test-applications/express-5/workers/instrument.server.ts b/dev-packages/e2e-tests/test-applications/express-5/workers/instrument.server.ts new file mode 100644 index 000000000000..5ccc34df1406 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/express-5/workers/instrument.server.ts @@ -0,0 +1,8 @@ +import { defineCloudflareOptions } from '@sentry/cloudflare'; + +export default defineCloudflareOptions({ + environment: 'qa', // dynamic sampling bias to keep transactions + dsn: 'https://username@domain/123', + tunnel: 'http://localhost:3031/', // proxy server + tracesSampleRate: 1, +}); diff --git a/dev-packages/e2e-tests/test-applications/express-5/wrangler.jsonc b/dev-packages/e2e-tests/test-applications/express-5/wrangler.jsonc new file mode 100644 index 000000000000..cdb29367f60d --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/express-5/wrangler.jsonc @@ -0,0 +1,7 @@ +{ + "$schema": "node_modules/wrangler/config-schema.json", + "name": "express-5", + "compatibility_date": "2026-06-29", + "compatibility_flags": ["nodejs_compat"], + "main": "./workers/app.ts", +} diff --git a/dev-packages/e2e-tests/test-applications/node-express-v5/.gitignore b/dev-packages/e2e-tests/test-applications/node-express-v5/.gitignore deleted file mode 100644 index 1521c8b7652b..000000000000 --- a/dev-packages/e2e-tests/test-applications/node-express-v5/.gitignore +++ /dev/null @@ -1 +0,0 @@ -dist diff --git a/dev-packages/e2e-tests/test-applications/node-express-v5/package.json b/dev-packages/e2e-tests/test-applications/node-express-v5/package.json deleted file mode 100644 index e19315dc2c42..000000000000 --- a/dev-packages/e2e-tests/test-applications/node-express-v5/package.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "node-express-v5-app", - "version": "1.0.0", - "private": true, - "scripts": { - "build": "tsc", - "start": "node dist/app.js", - "test": "playwright test", - "clean": "npx rimraf node_modules pnpm-lock.yaml", - "test:build": "pnpm install && pnpm build", - "test:assert": "pnpm test" - }, - "dependencies": { - "@modelcontextprotocol/sdk": "^1.26.0", - "@sentry/node": "file:../../packed/sentry-node-packed.tgz", - "@trpc/server": "11.8.1", - "@trpc/client": "11.8.1", - "@types/express": "^4.17.21", - "@types/node": "^18.19.1", - "express": "^5.1.0", - "mysql": "^2.18.1", - "typescript": "~5.7.2", - "zod": "~3.25.0" - }, - "devDependencies": { - "@playwright/test": "1.64.1", - "@sentry-internal/test-utils": "file:../../packed/sentry-internal-test-utils-packed.tgz", - "@sentry/core": "file:../../packed/sentry-core-packed.tgz" - } -} diff --git a/dev-packages/e2e-tests/test-applications/node-express-v5/playwright.config.mjs b/dev-packages/e2e-tests/test-applications/node-express-v5/playwright.config.mjs deleted file mode 100644 index d5fd0b394f15..000000000000 --- a/dev-packages/e2e-tests/test-applications/node-express-v5/playwright.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { getPlaywrightConfig } from '@sentry-internal/test-utils'; - -const config = getPlaywrightConfig({ - startCommand: `pnpm start`, -}); - -export default { - ...config, - globalSetup: './global-setup.mjs', - globalTeardown: './global-teardown.mjs', -};