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

wskdebug does not work with new vs code debugger #74

Closed
alexkli opened this issue Jul 16, 2020 · 9 comments · Fixed by #82
Closed

wskdebug does not work with new vs code debugger #74

alexkli opened this issue Jul 16, 2020 · 9 comments · Fixed by #82
Labels
bug Something isn't working

Comments

@alexkli
Copy link
Contributor

alexkli commented Jul 16, 2020


Update: Solution 🎉

If you are coming here from the warning given by wskdebug WARNING: wskdebug itself is debugged and likely NOT the action, then you have to update your VS Code launch config.

Starting with VS Code 1.48+ these settings are required to work with wskdebug:

            "type": "pwa-node",
            "request": "launch",
            "attachSimplePort": 0,
            "killBehavior": "polite",

Here is a complete example - adjust the args and name as needed:

    "configurations": [
        {
            "name": "wskdebug MYACTION", // <-- adjust name for debug drop-down
            "type": "pwa-node",
            "request": "launch",
            "attachSimplePort": 0,
            "killBehavior": "polite",
            "runtimeExecutable": "wskdebug",
            "args": [
                "MYACTION",  // <-- replace with name of the action
                "ACTION.js", // <-- replace with local path to action source file
                "--cleanup", // remove helper actions on shutdown
                "-l",        // enable live-reload
                "-v"         // log parameters and results
            ],
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "/code",
            "outputCapture": "std"
        }
    ]

This is also documented here: https://github.com/apache/openwhisk-wskdebug#nodejs-visual-studio-code


.
.
.

Original issue:

Problem

The new VS code debugger recently released (?) no longer sets --inspect-brk=XXXX for the debug port which wskdebug can intercept, but instead sets a NODE_OPTIONS with a custom --require that loads a (large) VS code javascript file into the process which apparently sets up debugging internally. This leads to the wskdebug node process itself being debugged, not the actual action on the container.

Links

▶️ Solutions ◀️

Collecting all solutions here, will be kept updated.

Quick Workaround

Simple workaround for now: Disable the new debugger in VS Code by setting this in the user settings json:

"debug.javascript.usePreview": false

This will work as long as VS Code supports this feature.

Future fix

The new VS Code debugger will get some changes that make it work with wskdebug. To get a preview, one has to install the VS code debugger nightly. Do this at your own risk.

  1. install nightly of debugger plugin (after July 16)
  2. in launch config have this:
    {
       "type": "pwa-node", // important
       "request": "launch",
       "name": "wskdebug",
       "attachSimplePort": 0, // instead of "port", makes it auto-select a free debug port
  3. use latest wskdebug 1.3.0 RC. install the pre-release from github directly:
    npm install -g https://github.com/apache/openwhisk-wskdebug
    
@alexkli
Copy link
Contributor Author

alexkli commented Jul 16, 2020

Fix with new vs code debugger nightly

  1. install nightly of debugger plugin (after July 16 evening PST)
  2. in launch config have this:
    {
       "type": "pwa-node", // important
       "request": "launch",
       "name": "wskdebug",
       "attachSimplePort": 0, // instead of "port", makes it auto-select a free debug port
       "killBehavior": "polite"

Problem: requires to hardcode the port number. See microsoft/vscode-js-debug#630 (comment)

@alexkli alexkli added this to the 1.3 milestone Jul 17, 2020
alexkli added a commit that referenced this issue Jul 21, 2020
- detect problematic case and print big warning and help
- document in readme
rabbah pushed a commit that referenced this issue Jul 22, 2020
- detect problematic case and print big warning and help
- document in readme
@alexkli alexkli removed this from the 1.3 milestone Jul 22, 2020
@alexkli
Copy link
Contributor Author

alexkli commented Jul 22, 2020

An initial improvement is in for the upcoming 1.3 release (detect problematic case & warn user, updated documentation). Keeping this issue open to track the changes on the VS code side and make any updates to the code or in documentation once those are released.

@alexkli alexkli added the bug Something isn't working label Jul 22, 2020
@alexkli
Copy link
Contributor Author

alexkli commented Aug 26, 2020

VS Code July 2020 release (1.48.x) includes the necessary changes enabling use of wskdebug with the new debugger, except for proper shutdown handling microsoft/vscode-js-debug#630. We could update the documentation accordingly now.

@davidjgonzalez
Copy link

@alexkli so to be clear, VS Code 1.48.x does NOT need this fix, and the wskdebug module (v1.3.0) available on npmjs today will work with VSCode 1.48.x (other than the inability to exit the debugger process)

@alexkli
Copy link
Contributor Author

alexkli commented Sep 8, 2020

@davidjgonzalez with VS Code 1.48.x you have to use a different config in launch.json than before to make it work. see above: #74 (comment)

@davidjgonzalez
Copy link

so would a 1.48.x compat launch.json look like:

{
    "type": "pwa-node",
    "request": "launch",
    "name": "wskdebug",
    "attachSimplePort": 0,
    "runtimeExecutable": "wskdebug",
    "args": [
        "foo-0.0.1/__secured_worker",  
        "${workspaceFolder}/actions/worker/index.js",  
        "-l",
        "--ngrok"
    ],
    "localRoot": "${workspaceFolder}",
    "remoteRoot": "/code",
    "outputCapture": "std",
    "timeout": 30000
}

Im not sure where the your example snippet in #74 (comment) "ends" and the "normal" config resumes for it to work properly.

@alexkli
Copy link
Contributor Author

alexkli commented Sep 8, 2020

@davidjgonzalez I believe so, but we'll provide updated documentation soon. this has to be tested first (I haven't tested anything with 1.48.x yet, only with that older nightly from some weeks ago).

For now the simplest as end user is to use the "debug.javascript.usePreview": false workaround.

@alexkli
Copy link
Contributor Author

alexkli commented Nov 25, 2020

VS Code now supports "killBehavior": "polite" to get SIGTERM to work again: microsoft/vscode-js-debug#630 (comment)

Need to test this and document.

alexkli added a commit that referenced this issue Dec 23, 2020
document new VS Code launch config starting with VS Code 1.48
@alexkli
Copy link
Contributor Author

alexkli commented Dec 23, 2020

The new launch config works fine. Documentation update in #82.

alexkli added a commit that referenced this issue Dec 23, 2020
document new VS Code launch config starting with VS Code 1.48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants