-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing source maps break client-side debugging under VSCode #56702
Comments
@carlo-salinari try replacing the content of
then, close all dev server and start debugging session in full stack mode |
This was helpful, thanks. Your Here's the one I ended up using (I've updated the reproduction repo):
I adapted it from the official documentation (it's in the Pages Router section, there's no Debugging section in the App Router section).
At this point I don't even know if the problem is with nextjs, vscode or chrome. |
@carlo-salinari maybe |
At least in my case, that was the issue. Component A included Component B which used I'm relatively new to Next.Js so I'm not certain if that is working as intended and it's just a matter of communicating this better. Or if this is a bug. |
Mine got fixed by changing the pattern for serverReadyAction in launch.json from "serverReadyAction": {
"pattern": "started server on .+, url: (https?://.+)",
"uriFormat": "%s",
"action": "debugWithChrome"
} to "serverReadyAction": {
"pattern": "- Local:.+(https?://.+)",
"uriFormat": "%s",
"action": "debugWithChrome"
} |
Has anyone figured out how to debug server-side by attaching to an already running process, instead of launching with My issue is if I use a config like: {
"type": "pwa-node",
"name": "attach test",
"request": "attach",
"processId": "${command:PickProcess}",
"cwd": "${workspaceFolder}"
}, and then start NextJS with VSCode will say "breakpoint can't be set" and offers debugging help that seems to suggest source maps aren't being generated. Indeed, if I attach using |
Seems that the discussion derailed from debugging client-side to server-side. I just fixed my client-side debugging issue today, and I find that the debugging documentation for TypeScript is lacking. Solution@carlo-salinari , I assume your issue is similar to mine, which is the problem on how to set up the The setup is dependent whether you use Turbopack or not. Without TurbopackCredit to this article although there's a typo with {
"name": "Next.js: debug client-side",
"type": "msedge",
"request": "launch",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack://_N_E/*": "${webRoot}/*"
}
} With Turbopack{
"name": "Next.js: debug client-side",
"type": "msedge",
"request": "launch",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}",
"sourceMaps": true,
"sourceMapPathOverrides": {
"/turbopack/[project]/*": "${webRoot}/*"
}
} How to diagnose the problem in the futureTLDR; use VSCode debug diagnostic to match the sourcemap path I fixed the above problem by opening the devtool in the browser first and see the source tree first, to get a better feel of the TypeScript file structure Then in VSCode, you open Debug Diagnostics (accessible via Command Palette). Select "What scripts and sourcemaps are loaded". Filter for the TSX file you're looking for, then you can grab the referenced from sourcemap to your |
@Skarvion thanks for the hint. |
@carlo-salinari I just checked my environment, it comes from an extension called JavaScript Debugger. Apparently, it's a built-in extension, it should already be enabled for VSCode 1.46 onward. First time seeing a built-in extension, you can't even check it with Anyway, step by step:
|
Fyi, my solution, where the client-side breakpoints just stopped working, was to close (and reopen) all my VSCode instances and then retry. |
Thank you very much, @carlo-salinari . Now I got turbopack working with debugging, the lack of which prevented me to use it For server and client side debugging, I just added { "name": "turbo",
"type": "node-terminal",
"request": "launch",
"command": "npm run turbo",
"serverReadyAction": {
"pattern": "- Local:.+(https?://.+)",
"uriFormat": "%s",
"action": "debugWithChrome"
},
"sourceMapPathOverrides": {
"/turbopack/[project]/*": "${webRoot}/*"
}
}
|
Hi everyone, thanks for your help and digging into this–– Curious if y'all have had any luck with getting server side files to work, cross-posting from #62008 (comment) |
{
"version": "0.2.0",
"configurations": [
{
"name": "Next.js: debug server-side",
"type": "node-terminal",
"request": "launch",
"command": "npm run dev --turbo"
},
{
"name": "Next.js: debug client-side",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000"
},
{
"name": "Next.js: debug full stack",
"type": "node-terminal",
"request": "launch",
"command": "npm run dev --turbo",
"skipFiles": ["<node_internals>/**"],
"sourceMaps": true,
"sourceMapPathOverrides": {
"/turbopack/[project]/*": "${webRoot}/*"
},
"serverReadyAction": {
"action": "debugWithEdge",
"killOnServerStop": true,
"pattern": "- Local:.+(https?://.+)",
"uriFormat": "%s",
"webRoot": "${workspaceFolder}"
}
}
]
} |
In my case, I was not able to debug with vscode due to source map issues when a the new vscode version 1.95 came up.
|
Link to the code that reproduces this issue
https://github.com/carlo-salinari/debug-nextjs
To Reproduce
npm run dev
page.tsx
Current vs. Expected behavior
Current behaviour:
dbconsole.txt
Expected:
Verify canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #34~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 7 13:12:03 UTC 2 Binaries: Node: 19.4.0 npm: 9.2.0 Yarn: 1.22.19 pnpm: 8.9.0 Relevant Packages: next: 13.5.5-canary.5 eslint-config-next: 13.5.4 react: 18.2.0 react-dom: 18.2.0 typescript: 5.2.2 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Not sure
Additional context
No response
The text was updated successfully, but these errors were encountered: