question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Local debugging in VS Code fails after app restart

See original GitHub issue

Repro steps:

  1. Start a PowerShell Function app in VS Code by F5.
  2. Wait for the app to start. Invoke a function or do not invoke any function - does not seem to matter.
  3. Stop the app: hit the Disconnect button or push Ctrl-C in the terminal.
  4. Start the app again by F5. About 2-5 seconds after the app start, it stops and the following message appears in the terminal window: Debug-Runspace: You cannot debug the default host Runspace using this cmdlet. To debug the default Runspace use the normal debugging commands from the host.

Further attempts to start the app fail with the same error, until VS Code is restarted.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ejizbacommented, Sep 15, 2020

Tried it out and I can repro on the latest func cli, but not on v3.0.2798. We changed (cc @pragnagopa) the message indicating when VS Code could attach the debugger to a debug-specific message (“Worker process started and initialized”) that was supposed to be more reliable than the old/arbitrary message we were using (“Host lock lease acquired by instance ID”). I would guess this is a timing problem and for some reason the new message is printed too early for us to attach, but I have no idea how this PowerShell stuff works under the covers or what could be happening during the time between messages

Here are two workarounds in the meantime:

  1. Downgrade to v3.0.2798
  2. Modify your .vscode/tasks.json to use the old message:
    {
      "version": "2.0.0",
      "tasks": [
        {
          "type": "func",
          "command": "host start",
          "problemMatcher": {
            "base": "$func-watch",
            "background": {
              "activeOnStart": true,
              "beginsPattern": "^.*(Job host stopped|signaling restart).*$",
              "endsPattern": "^.*Host lock lease acquired by instance ID.*$"
            }
          },
          "isBackground": true
        }
      ]
    }
    
1reaction
JustinGrotecommented, Sep 14, 2020

This is happening to me @AnatoliB after upgrading to Core Tools 3.0.2881 Runtime 3.0.14287.0 Powershell Worker 3.0.293 using the Attach to Powershell Functions in VSCode

Also nothing works at the debug prompt in the integrated console (7.0.3), every command just hangs until I step but the command never evaluates. Watch variables still work though

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debug in visual studio code is not working
Very simple solution is -> just uninstall debugger and delete launch.json file After that reinstall debugger then start.
Read more >
Debugging in Visual Studio Code
To run or debug a simple app in VS Code, select Run and Debug on the Debug start view or press F5 and...
Read more >
Troubleshoot Terminal launch failures
You can try killing unused programs and processes on your machine in case one of them is keeping a terminal shell process active...
Read more >
Debug Node.js Apps using Visual Studio Code
The Visual Studio Code editor includes Node.js debugging support. Set breakpoints, step-in, inspect variables and more.
Read more >
Remote Development Tips and Tricks
Visual Studio Code Remote Development troubleshooting tips and tricks for SSH, Containers, and the Windows Subsystem for Linux (WSL)
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found