Ensure debugging server-side code (app router) in VSCode works
Is there an existing issue for this?
- [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- [x] I have reviewed the documentation https://docs.sentry.io/
- [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/nextjs
SDK Version
9.40.0
Framework Version
Next 15.0.0
Link to Sentry event
No response
Reproduction Example/SDK Setup
https://github.com/HeroJourneyClub/WithSentryDebugger/tree/master
Issue Description
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.
Steps to Reproduce
How to Test
Test Case 1: Without Sentry (Breakpoints Work)
- 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
Test Case 2: With Sentry (Breakpoints Do Not Work)
- 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)
VS Code Launch Configuration
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"
}
}
]
}
Expected Result
Breakpoints are working
Actual Result
Breakpoints are not working
We're looking into this
Hey @msimon thanks for the detailed repro! Sorry for the delay, but we need to backlog this issue for now as we're quite busy – but it is on our list. Feel free to share any findings in this ticket in case you want to have a go at this, contributions are always welcome!
Hey @chargome, No worries, totally get it. The workaround isn't to bad.
Thanks