This repository demonstrates an issue where breakpoints don't work when Sentry is enabled using withSentryConfig.
- Clone this repository
- Install dependencies:
yarn install
When using Sentry's withSentryConfig in next.config.mjs, breakpoints set in both the middleware (src/middleware.ts) and API routes don't work. This can be demonstrated using two different launch configurations.
- In VS Code, select the "WITHOUT SENTRY: debug server-side" configuration
- Start debugging (F5)
- Set breakpoints in:
src/middleware.tsat the line withconsole.log("Add a breakpoint here")src/app/api/test/route.tsat the lines withconsole.log("Add a breakpoint here")
- Visit http://localhost:3000 and click either the "Test GET Request" or "Test POST Request" button
- Observe that all breakpoints are hit and debugging works as expected
- In VS Code, select the "WITH SENTRY: debug server-side" configuration
- Start debugging (F5)
- Set breakpoints in:
src/middleware.tsat the line withconsole.log("Add a breakpoint here")src/app/api/test/route.tsat the lines withconsole.log("Add a breakpoint here")
- Visit http://localhost:3000 and click either the "Test GET Request" or "Test POST Request" button
- Observe that none of the breakpoints are hit (although the console.log outputs appear in the terminal)
The repository includes the following launch configuration in .vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "WITH SENTRY: debug server-side",
"type": "node-terminal",
"request": "launch",
"command": "yarn dev",
"env": {
"WITH_SENTRY": "true"
}
},
{
"name": "WITHOUT SENTRY: debug server-side",
"type": "node-terminal",
"request": "launch",
"command": "yarn dev",
"env": {
"WITH_SENTRY": "false"
}
}
]
}- Next.js version: 15.4.1
- @sentry/nextjs version: 9.40.0
- Node.js version: v22.14.0
- Operating System: macOS 15.5
- The middleware contains a simple request ID generator and logger
- Console.log statements have been added at the locations where breakpoints should work
- The issue affects both middleware & route debugging when WithSentryConfig is enabled