Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAP (Debug Adapter Protocol) #8

Merged
merged 1 commit into from
Jul 2, 2023
Merged

Conversation

andresgutgon
Copy link
Owner

@andresgutgon andresgutgon commented Jun 24, 2023

WAT?

I want to be able to debug Node apps (Specially NextJS) app on backend side. nvim-dap use DAP protocol from Microsoft which is the one used by VSCode on their debugging experience. This is the same in Nvim.

To be honest this has been fucking painful for several reasons:

  1. First Next.js latest version has fucked their debugging experience. So I had to simplify the problem and first understand how node --inspect flag works on a simple Node server. Then I look into existing issues on Next.js and I discoverd that their debugging experience is broken in latest version. A fix is comming in this PR
  2. Second. After setting the nvim-dap plugin with the VSCode / JS debugging experience I spent a shameful amount of time hitting node-terminal debug mode when in reality was pwa-node. Yes, pwa is ultra weird and that took me time to figure out. Issue here about it
image

TODO

  • Understand how it works
  • Setup nice debug line symbols
  • Setup Dap UI with nice defaults
  • Setup dap virtual text
  • Take a look to mason installation for dap adapters. Doesn't work. Maybe in the future
  • Test on a simple javascript next app
  • Test on a pnpm turbo repo next app.

FUCK! This was hard 馃槀

I want to be able to debug Node apps (Specially NextJS) app on backend
side. nvim-dap use DAP protocol from Microsoft which is the one used by
VSCode on their debugging experience. This is the same in Nvim.

To be honest this has been fucking painful for several reasons.
1. First Next.js latest version has fucked their debugging experience.
   So I had to simplify the problem and first understand how node
   `--inspect` flag works on a simple Node server. Then I look into
   existing issues on Next.js and I discoverd that their debugging
   experience is broken in latest version. A [fix is comming in this PR](vercel/next.js#51467)
2. Second. After setting the `nvim-dap` plugin with the VSCode / JS
   debugging experience I spent a shameful amount of time hitting
   `node-terminal` debug mode when in reality was `pwa-node`. Yes, `pwa`
   is ultra weird and that took me time to figure out. [Issue here about
   it](microsoft/vscode#151910)

FUCK! This was hard 馃槀
name = "Attach to process",
type = "pwa-node",
request = "attach",
processId = dap_utils.pick_process,
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only way I managed to make this debugger in NextJS was by picking the process. At the moment I don't need to specify a .vscode/launch.json in my project. I just lunch the DAP UI and pick the process for the next app running in debug mode.

My package.json

"dev": "pnpm dev",
"dev:debug": "NODE_OPTIONS='--inspect' pnpm dev",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant