sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Ensure debugging server-side code (app router) in VSCode works

Open msimon opened this issue 6 months ago • 4 comments

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)

  1. In VS Code, select the "WITHOUT SENTRY: debug server-side" configuration
  2. Start debugging (F5)
  3. Set breakpoints in:
    • src/middleware.ts at the line with console.log("Add a breakpoint here")
    • src/app/api/test/route.ts at the lines with console.log("Add a breakpoint here")
  4. Visit http://localhost:3000 and click either the "Test GET Request" or "Test POST Request" button
  5. Observe that all breakpoints are hit and debugging works as expected

Test Case 2: With Sentry (Breakpoints Do Not Work)

  1. In VS Code, select the "WITH SENTRY: debug server-side" configuration
  2. Start debugging (F5)
  3. Set breakpoints in:
    • src/middleware.ts at the line with console.log("Add a breakpoint here")
    • src/app/api/test/route.ts at the lines with console.log("Add a breakpoint here")
  4. Visit http://localhost:3000 and click either the "Test GET Request" or "Test POST Request" button
  5. 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

msimon avatar Jul 18 '25 13:07 msimon

We're looking into this

RulaKhaled avatar Jul 21 '25 14:07 RulaKhaled

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!

chargome avatar Jul 29 '25 12:07 chargome

Hey @chargome, No worries, totally get it. The workaround isn't to bad.

Thanks

msimon avatar Aug 14 '25 10:08 msimon