PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code
https://marketplace.visualstudio.com/items/ms-vscode.PowerShell
MIT License
1.69k stars 479 forks source link

PowerShell terminal Fails on Start-up #3146

Closed RichieBzzzt closed 1 year ago

RichieBzzzt commented 3 years ago

Issue Description

I am experiencing a problem with running the Powershell terminal. It loads up then stops, and no matter how many times I try to restart it crashes. It worked for a while with some files but others it does not. I am unable to get a consistent reproduction, but it happens 99 times out of 100. I have tried the PowerShell Preview extension and that crashes.

It had been working fine no issues form about July last year, this is only a very recent issue. I'm not aware of an update to VS Code, the extension or PowerShell.

psfailure owershell terminal.

Attached Logs

traceserver.txt 1611573964-f1fd79f0-5c46-45b9-97ae-a9bc090f420e1611573760719.zip

Environment Information

Visual Studio Code

Name Version
Operating System Linux x64 5.4.0-62-generic
VSCode 1.52.1
PowerShell Extension Version 2020.6.0

PowerShell Information

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand) |Extension|Author|Version| |---|---|---| |azure-account|ms-vscode|0.9.4| |azure-pipelines|ms-azure-devops|1.183.0| |Because|selfrefactor|1.8.0| |inbedby7pm|sdras|0.4.0| |jupyter|ms-toolsai|2020.12.414227025| |linux-themes|SolarLiner|1.0.1| |night-owl|sdras|2.0.0| |parisienne|richiebzzzt|0.2.15| |powershell|ms-vscode|2020.6.0| |python|ms-python|2021.1.502429796| |remote-containers|ms-vscode-remote|0.155.1| |shades-of-purple|ahmadawais|6.12.0| |spectral-glow|mediumdivision|1.0.0| |synthwave-vscode|RobbOwen|0.1.8| |terraform|hashicorp|2.5.0| |terraform-advanced-syntax-highlighting|pjmiravalle|1.3.0| |theme-dracula|dracula-theme|2.22.3| |tokyo-hack|ajshortt|0.3.2| |vscode-docker|ms-azuretools|1.9.1| |vscode-yaml|redhat|0.14.0| |yaru-vscode|AdsonCicilioti|0.1.3|
SydneyhSmith commented 3 years ago

Thanks @RichieBzzzt for providing the logs, that is very helpful! Was there any output in the console when you tried starting up with the Preview extension? Also you you know of any configuration changes that were made on your machine ex. group policy or security changes? We did notice this stack trace:

Error: Connection got disposed.
    at Object.dispose (/home/richie/.vscode/extensions/ms-vscode.powershell-2020.6.0/node_modules/vscode-jsonrpc/lib/main.js:904:25)
    at Object.dispose (/home/richie/.vscode/extensions/ms-vscode.powershell-2020.6.0/node_modules/vscode-languageclient/lib/client.js:74:35)
    at LanguageClient.handleConnectionClosed (/home/richie/.vscode/extensions/ms-vscode.powershell-2020.6.0/node_modules/vscode-languageclient/lib/client.js:2309:42)
    at LanguageClient.handleConnectionClosed (/home/richie/.vscode/extensions/ms-vscode.powershell-2020.6.0/node_modules/vscode-languageclient/lib/main.js:155:15)
    at closeHandler (/home/richie/.vscode/extensions/ms-vscode.powershell-2020.6.0/node_modules/vscode-languageclient/lib/client.js:2296:18)
    at CallbackList.invoke (/home/richie/.vscode/extensions/ms-vscode.powershell-2020.6.0/node_modules/vscode-jsonrpc/lib/events.js:62:39)
    at Emitter.fire (/home/richie/.vscode/extensions/ms-vscode.powershell-2020.6.0/node_modules/vscode-jsonrpc/lib/events.js:121:36)
    at closeHandler (/home/richie/.vscode/extensions/ms-vscode.powershell-2020.6.0/node_modules/vscode-jsonrpc/lib/main.js:240:26)
    at CallbackList.invoke (/home/richie/.vscode/extensions/ms-vscode.powershell-2020.6.0/node_modules/vscode-jsonrpc/lib/events.js:62:39)
    at Emitter.fire (/home/richie/.vscode/extensions/ms-vscode.powershell-2020.6.0/node_modules/vscode-jsonrpc/lib/events.js:121:36)
    at StreamMessageWriter.fireClose (/home/richie/.vscode/extensions/ms-vscode.powershell-2020.6.0/node_modules/vscode-jsonrpc/lib/messageWriter.js:39:27)
    at Socket.<anonymous> (/home/richie/.vscode/extensions/ms-vscode.powershell-2020.6.0/node_modules/vscode-jsonrpc/lib/messageWriter.js:58:46)
    at Socket.emit (events.js:228:7)
    at Pipe.<anonymous> (net.js:664:12)

Curious if you are using VSCode in a remoting context?

RichieBzzzt commented 3 years ago

Hello! To my best knowledge, this machine has no group policy or security changes; it's my own personal laptop so it's not connected to a domain. However I'm not clear on what that stack trace is telling you; could you clarify so I can check my machine?

I have attached a couple of gifs that show the behaviour. When I open this ps1 file the terminal loads up and doesn't crash. psworks

However with this other PowerShell file I open it up and it crashes the terminal, and no matter how many times I try to restart the session it crashes. psfailed

I have noticed that it tends to crash files that have more code in them or have been pasted into. IDK if that info is useful or not though!

RichieBzzzt commented 3 years ago

Update: I uninstalled all of my modules and opened VS Code and the PowerShell terminal runs fine. Opening any number of scripts causes not to crash. So I installed the Az module and the problem came back.

I noticed that a lot of my scripts use cmdlets from the Az.Storage module and so I uninstalled all of Az and installed only Az.Storage 3.2.1, and any files that contained cmdlets from the Az.Storage module caused it to crash. Updating to allow for pre-release installs version 4.0.2-preview and I am able to open those PowerShell files without the terminal crashing.

Sadly that is not the end of it: any cmdlets from Az.DataLakeStore also cause the terminal to crash. That is on latest version (1.3.0) so I downgraded to .1.2.8 and it still crashed.

I have opened other PowerShell files that don't use the Az module and the terminal does not crash.

Am happy to send logs from latest efforts if you think they'll help.

SydneyhSmith commented 3 years ago

Thanks @RichieBzzzt for providing all of that information that is a helpful update...it seems as though something is causing a deep crash in the extension but it will take more investigation to find out...could you try the PowerShell Preview extension, we have some additional logging in that update? Thanks!

RichieBzzzt commented 3 years ago

Apologies for the delay, here is the logging using PowerShell preview 2020.9.0

Let me know if I can help any further :-)

1612770659-0b5a6c5f-fee1-409c-a9c2-977a499b405a1612770575448.zip

SydneyhSmith commented 3 years ago

Thanks @RichieBzzzt for all of the logs

ghost commented 3 years ago

This issue was closed automatically as repro info was indicated as needed, but there has been no activity in over a week. Please feel free to reopen with any available information!

andyleejordan commented 3 years ago

This definitely had repro info, and what's more, looks like it might be an external issue (or at least an interaction with an external module). Could you test the latest preview extension that went up today, v2021.8.1-preview?

andyleejordan commented 1 year ago

Hey @RichieBzzzt! I'm hoping this has since been resolved, please let me know if not otherwise the bot should close it out in a week.

RichieBzzzt commented 1 year ago

Hello yes that’s fine, I was happy to see it closed didn’t realise this issue reopened.

ghost commented 1 year ago

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