Skip to content

NODE Cluster Debugger(Inspector) problem #39033

Closed

Description

  • VSCode Version: 1.18.1
  • OS Version: Windows 10 64bits
  • Node Version: 8.6.0

When debugguing nodeJS applications in cluster mode, the debugger starts correctly but it does not print any console messages but the main/initialization ones. The debugger(Inspector) does not catch any break points.
It happens 50% of time, sometimes it works sometimes it doesn't.
It has started after the update that added the "outputCapture: std" option, when using std it duplicates all the console messages.

My launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "protocol": "inspector",
            "outputCapture": "console",
            "name": "Launch WBA",
            "useWSL": false,
            "env": {
                "NODE_ENV": "development"
            },
            "cwd": "${workspaceRoot}/server",
            "outFiles": [
                "${workspaceRoot}/server/dist/**/*.js.map",
                "${workspaceRoot}/server/dist/**/*.js"
            ],
            "program": "${workspaceRoot}/server/src/Main.ts",
            "runtimeExecutable": null,
            "runtimeArgs": [
                "--nolazy",
                "--no-warnings",
                "--expose-gc",
                "--inspect=9329"
            ],
            "stopOnEntry": false,
            "sourceMaps": true,
            "address": "localhost",
            "port": 9329
        },
        {
            "name": "Launch WBA Chrome",
            "type": "chrome",
            "request": "launch",
            "url": "https://localhost:3000",
            "webRoot": "${workspaceRoot}/template",
            "sourceMaps": true
        },
        {
            "type": "node",
            "request": "attach",
            "protocol": "inspector",
            "name": "Attach to worker 1",
            "stopOnEntry": false,
            "address": "localhost",
            "port": 9330,
            "timeout": 30000
        },
        {
            "type": "node",
            "request": "attach",
            "protocol": "inspector",
            "name": "Attach to worker 2",
            "stopOnEntry": false,
            "address": "localhost",
            "port": 9331,
            "timeout": 30000
        },
        {
            "type": "node",
            "request": "attach",
            "protocol": "inspector",
            "name": "Attach to worker 3",
            "stopOnEntry": false,
            "address": "localhost",
            "port": 9332,
            "timeout": 30000
        },
        {
            "type": "node",
            "request": "attach",
            "protocol": "inspector",
            "name": "Attach to worker 4",
            "stopOnEntry": false,
            "address": "localhost",
            "port": 9333,
            "timeout": 30000
        }
    ],
    "compounds": [
        {
            "name": "Debug Cluster",
            "configurations": [
                "Launch WBA",
                "Attach to worker 1",
                "Attach to worker 2",
                "Launch WBA Chrome"
            ]
        }
    ]
}

Cluster and worker initialization:

node --nolazy --no-warnings --expose-gc --inspect=9329 dist\Main.js 
Debugger listening on ws://127.0.0.1:9329/876fe2a6-67c9-4786-81c7-f9f3cf7e7756
WBA Cluster 6520 is running, available CPUS: 4 - Args ["--nolazy","--no-warnings","--expose-gc","--inspect=9329"]
Worker Id: 2 - PID: 7936 - Args ["--nolazy","--no-warnings","--expose-gc","--inspect=9329","--inspect-port=9331"]
Worker Id: 1 - Name: fileIntegrationWorker - PID: 12864 - Args ["--nolazy","--no-warnings","--expose-gc","--inspect=9329","--inspect-port=9330"]

tsconfig.json:

{
  "compilerOptions": {
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "target": "ES6",
    "module": "commonjs",
    "outDir": "dist",
    "rootDir": "src",
    "sourceMap": true,
    "typeRoots": [
      "node_modules/@types"
    ],
    "types": [
      "node"
    ]
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "node_modules",
    "dist"
  ]
}

Please let me know if you need more info.

Thanks!

Activity

  1. added
    debug
    on Nov 23, 2017
  2. roblourens commented on Dec 8, 2017

    @roblourens
    Member

    Could you run this with "trace": true and upload the log here? Thanks

  3. added
    info-needed
    on Dec 8, 2017
  4. gustavomassa commented on Dec 8, 2017

    @gustavomassa
    Author

    Hi Rob,

    The log is attached. One thing that I observed is that sometimes it stops on the beginning of the class, even though there is not breakpoint there and "stopOnEntry" is false.

    vscode-node-debug2.txt

    Thanks

  5. roblourens commented on Dec 8, 2017

    @roblourens
    Member

    I guess that doesn't help me since it's not the log from the workers.

    I've never tried this but I'm not sure why it wouldn't work. I guess I'm not sure exactly what the problems are though - is it printing log messages from the initial process, but not the worker processes, even when you are attached to them? When you use "outputCapture": "std", you see all the messages, but duplicated?

    The debugger(Inspector) does not catch any break points.

    So you can never hit breakpoints? In any process or just in the worker processes?

    It happens 50% of time, sometimes it works sometimes it doesn't.

    Referring to log messages or breakpoints? Any pattern to this?

    If you can share the project that would be really helpful.

  6. gustavomassa commented on Dec 8, 2017

    @gustavomassa
    Author

    Issue 1: Duplicated console messages when using "outputCapture": "std"
    Issue2: Workers breakpoints are not working correctly, sometimes it works sometimes it does not, when it does not work, the console messages are not duplicated.

    So you can never hit breakpoints? In any process or just in the worker processes?
    I can, 50% of the time, just for worker process.

    It happens 50% of time, sometimes it works sometimes it doesn't.
    Referring to breakpoints, sometimes it catchs sometimes not. (Just for workers). When the worker breakpoints are working, the console messages are duplicated.

    This is the log related just to workers debug. This log is a case when the workers breakpoints started working normally(Hitting breakpoints), but after debugging using F6 and the debugger entered on an internal breakpoint then stopped working.
    OBS: I'm debugging .ts files using sourmaps.

    Unfortunately I can't share the entire project, but feel free to ask anything else.

    vscode-node-debug2.txt

    Thanks

  7. gustavomassa commented on Dec 12, 2017

    @gustavomassa
    Author

    New issues:

    1 - Sometimes when debugging with F5 the debugger gets lost, and goes into .js files rather than .ts files.
    No pattern identified yet.
    2 - Sometimes Vscode breakpoints disappear, but it stills catch the breakpoints, so you need to add and then remove the breakpoint again to fix it.

    This is a .zip containing the main files of cluster and server, also the vscode folder and gulpfile used to generate the .js files. Please let me know if you need anything else.

    vscode.zip

    Thanks

  8. weinand commented on Dec 12, 2017

    @weinand
    Contributor

    Gustavo Massaneiro (@gustavomassa) You might want to try this: #40123

  9. gustavomassa commented on Dec 13, 2017

    @gustavomassa
    Author

    Andre Weinand (@weinand)

    Sure! How can I help you testing it?
    I don't think my issues are related to debugger being able to attach the workers correctly, because vscode always attaches to workers and start the workers code properly, but not always catch the workers breakpoints. But let me give it a try :)

    image

    I think my issues are related to the source map, the gulp is generating the sourcemaps inline properly, but for some reason sometimes vscode is not able to find it, maybe a timeout/synchronization issue.

    Thanks

  10. gustavomassa commented on Jan 12, 2018

    @gustavomassa
    Author

    Hello,

    Issue understood and resolved.
    I have 4 cores on my cluster, but I'm attatching just 2 workers on the Debuger, therefore the debugger was not catching the breakpoints but sometimes was. The reason is simple, I have 4 workers running and just 2 debugguers attatched to it, so I had 50% of chance to attach the right worker and catch the breakpoint.
    The new feature "autoAttachChildProcesses" should fix the issue.

    Thank you!

  11. weinand commented on Jan 12, 2018

    @weinand
    Contributor

    Gustavo Massaneiro (@gustavomassa) thanks for coming back to us and closing this issue!

  12. removed
    info-needed
    on Jan 12, 2018
  13. locked and limited conversation to collaborators on Feb 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

debug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions