-
Notifications
You must be signed in to change notification settings - Fork 337
Description
Describe the bug
When using VS Code's JavaScript Debugger to attach to a Vite dev server, the breakpoint source maps behave inconsistently depending on the startup sequence.
✅ Works as expected (Case A)
- Start the debugger first, connecting.
- Then start the Vite dev server (pnpm dev / npm run dev / vite), debugger connected.
- Breakpoints map correctly to the expected source locations.
❌ Incorrect mapping (Case B)
- Start the Vite dev server first.
- Then start the debugger to attach to Chrome.
- Breakpoint locations become incorrectly set to the compiled file— VS Code jumps to the wrong lines/files.
- To make breakpoints map correctly again, I must manually run:
location.reload()
Launch.json
{
"name": "Attach Render",
"type": "chrome",
"request": "attach",
"port": 9222,
"timeout": 60000,
"urlFilter": "http://localhost/*",
"webRoot": "${workspaceFolder}/sdk/renderer",
"resolveSourceMapLocations": ["!**/node_modules/**"],
"skipFiles": ["**/node_modules/**"],
}
VS Code Version:
Additional context
I’m currently not able to provide the repository where the issue occurs, but I may try to create a minimal reproducible example when I have time.
The project affected by this bug is an Electron application whose renderer process is a multi-page Vite application.
Interestingly, I do not encounter this issue in another Electron project where the renderer is a single-page Vite application, so I’m not yet sure whether the bug is related to the multi-page setup, the Electron integration, or something else.
Sorry that I can’t share a more concrete reproduction at the moment.