Skip to content

Commit 8b22796

Browse files
betegonclaude
andcommitted
fix(e2e): use --import for Sentry ESM init in node-express-mcp-v2
The app runs as ESM ("type": "module") because the MCP SDK v2 packages are ESM-only. Sentry must be loaded via --import before the app module to instrument Express correctly; importing it inside app.ts is too late. Extracts Sentry.init() into instrument.mjs and starts the app with node --import ./instrument.mjs dist/app.js, matching the pattern used by tsx-express. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e3eed42 commit 8b22796

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import * as Sentry from '@sentry/node';
2+
3+
Sentry.init({
4+
environment: 'qa', // dynamic sampling bias to keep transactions
5+
dsn: process.env.E2E_TEST_DSN,
6+
debug: !!process.env.DEBUG,
7+
tunnel: `http://localhost:3031/`, // proxy server
8+
tracesSampleRate: 1,
9+
});

dev-packages/e2e-tests/test-applications/node-express-mcp-v2/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"scripts": {
66
"build": "tsc",
7-
"start": "node dist/app.js",
7+
"start": "node --import ./instrument.mjs dist/app.js",
88
"test": "playwright test",
99
"clean": "npx rimraf node_modules pnpm-lock.yaml",
1010
"test:build": "pnpm install && pnpm build",

dev-packages/e2e-tests/test-applications/node-express-mcp-v2/src/app.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
11
import * as Sentry from '@sentry/node';
2-
3-
Sentry.init({
4-
environment: 'qa', // dynamic sampling bias to keep transactions
5-
dsn: process.env.E2E_TEST_DSN,
6-
debug: !!process.env.DEBUG,
7-
tunnel: `http://localhost:3031/`, // proxy server
8-
tracesSampleRate: 1,
9-
});
10-
112
import express from 'express';
123
import { mcpRouter } from './mcp.js';
134

0 commit comments

Comments
 (0)