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.

[Powershell Preview regression bug] Debugger hangs when a breakpoint inside a scriptblock is hit

See original GitHub issue

Issue Description

I am experiencing a problem with the debugger. It hangs when a breakpoint inside a scriptblock is hit.

Steps to reproduce:

  • Paste the script as a new ps1 file, and run it.
  • In the Integrated terminal type ‘Stop-Service -Name <tab>’
  • The debug session is started, but it does not accept further interaction.
$s = {
    param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)
    Set-PSBreakpoint -command Get-Service
    $services = Get-Service | Where-Object {$_.Status -eq "Running" -and $_.Name -like "$wordToComplete*"}
    $services | ForEach-Object {
        New-Object -Type System.Management.Automation.CompletionResult -ArgumentList $_.Name,
            $_.Name,
            "ParameterValue",
            $_.Name
    }
}
Register-ArgumentCompleter -CommandName Stop-Service -ParameterName Name -ScriptBlock $s

Beyond this point, you can only kill the integrated terminal. It will not accept any other input. image

NOTE: This only happens in the PowerShell Preview Extension. The GA PowerShell extension does not have this bug.

The bug is also not reproducible in a stand alone console in PowerShell 5.1, Powershell 6.2.3, or 7.0.0.rc2, or PowerShell_ise (5.1). It is specific to the Preview version of the extension.

Attached Logs

1580281742-dc8c91be-e55c-4eed-822f-c087bed38b011580281219461.zip

Environment Information

Visual Studio Code

Name Version
Operating System Windows_NT x64 10.0.18363
VSCode 1.41.1
PowerShell Extension Version 2020.1.0

PowerShell Information

Name Value
PSVersion 7.0.0-rc.2
PSEdition Core
GitCommitId 7.0.0-rc.2
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions 1.0 2.0 3.0 4.0 5.0 5.1.10032.0 6.0.0 6.1.0 6.2.0 7.0.0-rc.2
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand)
Extension Author Version
azure-account ms-vscode 0.8.8
azure-pipelines ms-azure-devops 1.165.1
azurecli ms-vscode 0.4.6
bracket-pair-colorizer-2 CoenraadS 0.0.29
cmake twxs 0.0.17
code-settings-sync Shan 3.4.3
cpptools ms-vscode 0.26.3
csharp ms-vscode 1.21.9
csharpfixformat Leopotam 0.0.84
docomment k–kato 0.1.8
gitlab-ci-validator cstuder 1.0.0
gitlens eamodio 10.2.0
Go ms-vscode 0.12.0
LiveServer ritwickdey 5.6.1
powershell-preview ms-vscode 2020.1.0
python ms-python 2020.1.58038
remote-containers ms-vscode-remote 0.94.0
remote-ssh ms-vscode-remote 0.48.0
remote-ssh-edit ms-vscode-remote 0.48.0
remote-wsl ms-vscode-remote 0.41.7
swagger-viewer Arjun 2.2.2
terraform mauve 1.4.0
vscode-azurefunctions ms-azuretools 0.20.2
vscode-azureterraform ms-azuretools 0.3.0
vscode-icons vscode-icons-team 9.7.0
vscode-markdownlint DavidAnson 0.33.0
vscode-pull-request-github GitHub 0.14.0
vscode-remote-extensionpack ms-vscode-remote 0.19.0
vscode-svg-previewer vitaliymaz 0.5.1
vscode-typescript-tslint-plugin ms-vscode 1.2.3
vsliveshare ms-vsliveshare 1.0.1510
vsonline ms-vsonline 1.0.1507
xml DotJoshJohnson 2.5.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Jawz84commented, Jan 22, 2022

Agreed, thanks. Great work everyone!

1reaction
msftbot[bot]commented, Jan 22, 2022

This issue has been marked as fixed. It has been automatically closed for housekeeping purposes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how do I debug scriptblocks or background jobs - TechNet
I am trying to update an existing powershell script that makes extensive use of scriptblocks and Jobs. How do i set a breakpoint...
Read more >
Debugging 102: My script only crashes when I run it, never in ...
Now you remove the breakpoint and just run the script in the debugger, hoping it will crash and that the debugger will show...
Read more >
sitemap-topicarticle-1.xml - MuleSoft Help Center
... /How-to-enable-SSL-debug-logging-in-MuleSoft-Products 2022-11-30T04:21:01.000Z ... https://help.mulesoft.com/s/article/PowerShell-Connector-ScriptBlock- ...
Read more >
Excuse #1: We Couldn't Find Any Women - Endgame's Blog
Debugging in the kernel is different from other debugging problems. ... If you already have a BSOD crash dump file, in the WinDbg...
Read more >
.NET Core Guide - forum for Sthink members
Debugging in Debug mode. Setting a breakpoint. So far, you've followed the steps in Build a C# Hello World Application with .NET Core...
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