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.

Debugging with active breakpoint crashes Powershell session

See original GitHub issue

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.

Summary

Powershell session crashes in preview extension when attempting to debug a script with active breakpoint in unsaved file. Debugging the same code in a saved file works.

Also occurs when debugging Pester tests, but was able to reproduce the same exception in this simpler demo so I believe it might be the same root cause.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.1.3
PSEdition                      Core
GitCommitId                    7.1.3
OS                             Microsoft Windows 10.0.22000
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

1.62.0-insider
b3318bc0524af3d74034b8bb8a64df0ccf35549a
x64

Extension Version

ms-vscode.powershell-preview@2021.11.0

Steps to Reproduce

  1. Open a new unsaved file with content $a = 1
  2. Place a breakpoint on the line and launch/debug file as normal

Visuals

Repro pses3-debug-crash

Exception 115

Logs

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:20 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
JustinGrotecommented, Nov 4, 2021

I can consistently reproduce if you:

  1. Start a debug session (I use start interactive session)
  2. Run a pester test

I get the same scopes issue. Doesn’t happen if you don’t have a debug session started.

1reaction
JustinGrotecommented, Nov 5, 2021

Agreed, @andschwa there should be a broad catch for all otherwise-uncaught pwsh invocation exceptions that logs the exception occurred but doesn’t kill PSES (or at the very worst auto-restarts it)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging PowerShell script in Visual Studio Code – Part 1
In the first of this two-part series, we will cover the many features of the PowerShell debugger for Visual Studio Code. These features...
Read more >
Debug using the Just-In-Time Debugger - Visual Studio
If you once had Visual Studio installed, you may need to disable Just-In-Time debugging from the Windows registry. Enable or disable Just-In- ...
Read more >
Attach to running processes with the Visual Studio debugger
Discover how to attach the Visual Studio debugger to a running process on a local or remote computer.
Read more >
How to Debug Scripts in Windows PowerShell ISE
You can set three types of breakpoints in the Windows PowerShell debugging environment: Line breakpoint. The script pauses when the designated ...
Read more >
Debugging PowerShell Scripts in Visual Studio Code - YouTube
In this video, I show how to use the PowerShell Extension for Visual Studio Code to debug PowerShell scripts. We'll look at how...
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