Skip to content

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

@msimon

Description

@msimon

Is there an existing issue for this?

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

Metadata

Metadata

Assignees

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions