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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuxt3: Missing sourcemaps if debugger is attached. #1920

Closed
ayalon opened this issue Jan 13, 2024 · 2 comments
Closed

Nuxt3: Missing sourcemaps if debugger is attached. #1920

ayalon opened this issue Jan 13, 2024 · 2 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug *out-of-scope Posted issue is not in scope of VS Code

Comments

@ayalon
Copy link

ayalon commented Jan 13, 2024

Describe the bug
Debugging is not working with Nuxt3 if the debugger is attached.
But if the debugging process (server) is started from VSCode it works.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Reproduction repo debugdemo'
  2. Follow the Readme to set it up
  3. Attach the debugger, set a breakpoint: No hit
  4. Start the project from VSCode, set a breakpoint, Works!

Configuration

{
    "configurations": [
        {
            "address": "localhost",
            "name": "Attach to local",
            "port": 9229,
            "request": "attach",
            "type": "node",
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "${workspaceFolder}",
        },
        {
            "type": "node",
            "request": "launch",
            "name": "server: nuxt",
            "outputCapture": "std",
            "localRoot": "${workspaceFolder}",
            "program": "${workspaceFolder}/node_modules/nuxi/bin/nuxi.mjs",
            "args": [
                "dev"
            ],
            "outFiles": [
                "${workspaceFolder}/frontend/.nuxt/**/*",
            ]
        }
    ],
}

Log File

I analyzed the logfiles and the issue is, that the sourcemaps unter /.nuxt/dev are not loaded if the debugger is attached. If the debugging process is started from the terminal, these source maps can be found and the debugging works.

I'm super happy if someone could give me a hint how to use the "Attach" feature with Node with Nuxt3. As soon as I get this working, I could debug inside a docker container.

VS Code Version: 1.85.0

@ayalon ayalon added the bug Issue identified by VS Code Team member as probable bug label Jan 13, 2024
@connor4312
Copy link
Member

connor4312 commented Jan 16, 2024

This is a bug in Nuxt.js. When the main process is --inspect'ed, it will spawn its child with --inspect. But that listens on port 9229 by default, and if that port is in use (by the parent process listening on the same port, for example), the inspector fails to bind and it cannot be debugged.

https://github.com/nuxt/cli/blob/c448ade0ae58dff611bd01252c7ad10c76a805b6/src/commands/dev.ts#L171

When you start the process from VS Code, we don't pass in an --inspect flag (we use another mechanism to enable debugging) so it avoids the issue.

I suggest opening an issue on them for this.

@connor4312 connor4312 added the *out-of-scope Posted issue is not in scope of VS Code label Jan 16, 2024
@ayalon
Copy link
Author

ayalon commented Feb 6, 2024

Thank you so much for your help @connor4312.
You took the time to understand my issue and pointed me to the exact source of the problem. I even was able understand and fix the issue and use the debugger now inside a container with that knowledge.
I created a blog post on our company website to share how to debug Nuxt 3.
https://www.liip.ch/en/blog/nuxt3-node-debugging

Credits to you for pointing me to the right direction!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug *out-of-scope Posted issue is not in scope of VS Code
Projects
None yet
Development

No branches or pull requests

2 participants