vscode-powershell: Powershell terminated due to Untitled Files

Issue Type: Bug

when using VS Code to manage my 365 & Azure services my powershell is crashing all the time

The log:

1/7/2019 2:37:11 PM [NORMAL] - Visual Studio Code v1.30.1 64-bit
1/7/2019 2:37:11 PM [NORMAL] - PowerShell Extension v1.10.2
1/7/2019 2:37:11 PM [NORMAL] - Operating System: Windows 64-bit
1/7/2019 2:37:11 PM [NORMAL] - Path specified by 'powerShellExePath' setting - '' - not found, reverting to default PowerShell path.
1/7/2019 2:37:11 PM [NORMAL] - Language server starting --
1/7/2019 2:37:11 PM [NORMAL] -     exe: C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
1/7/2019 2:37:11 PM [NORMAL] -     args: C:\Users\USER\.vscode\extensions\ms-vscode.powershell-1.10.2\modules\PowerShellEditorServices\Start-EditorServices.ps1 -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '1.10.2' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'C:\Users\USER\.vscode\extensions\ms-vscode.powershell-1.10.2\modules' -EnableConsoleRepl -LogLevel 'Normal' -LogPath 'C:\Users\USER\.vscode\extensions\ms-vscode.powershell-1.10.2\logs\1546868231-e64619ea-75b4-4072-ad3f-e3d17d9cdc0a1546868227533\EditorServices.log' -SessionDetailsPath 'C:\Users\USER\.vscode\extensions\ms-vscode.powershell-1.10.2\sessions\PSES-VSCode-15988-512096' -FeatureFlags @()
1/7/2019 2:37:11 PM [NORMAL] - powershell.exe started, pid: 17224
1/7/2019 2:37:13 PM [NORMAL] - Language server started.
1/7/2019 2:37:13 PM [NORMAL] - {"languageServiceTransport":"NamedPipe","languageServicePipeName":"\\\\.\\pipe\\PSES_b1gpjnf0.2ul","debugServiceTransport":"NamedPipe","status":"started","debugServicePipeName":"\\\\.\\pipe\\PSES_nzcdqmkj.41o"}
1/7/2019 2:37:13 PM [NORMAL] - Connecting to language service on pipe \\.\pipe\PSES_b1gpjnf0.2ul...
1/7/2019 2:37:13 PM [NORMAL] - Language service connected.
1/7/2019 2:39:05 PM [NORMAL] - powershell.exe terminated or terminal UI was closed
1/7/2019 2:39:11 PM [NORMAL] - Shutting down language client...
1/7/2019 2:39:11 PM [NORMAL] - Path specified by 'powerShellExePath' setting - '' - not found, reverting to default PowerShell path.
1/7/2019 2:39:11 PM [NORMAL] - Language server starting --
1/7/2019 2:39:11 PM [NORMAL] -     exe: C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
1/7/2019 2:39:11 PM [NORMAL] -     args: C:\Users\USER\.vscode\extensions\ms-vscode.powershell-1.10.2\modules\PowerShellEditorServices\Start-EditorServices.ps1 -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '1.10.2' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'C:\Users\USER\.vscode\extensions\ms-vscode.powershell-1.10.2\modules' -EnableConsoleRepl -LogLevel 'Normal' -LogPath 'C:\Users\USER\.vscode\extensions\ms-vscode.powershell-1.10.2\logs\1546868351-e64619ea-75b4-4072-ad3f-e3d17d9cdc0a1546868227533\EditorServices.log' -SessionDetailsPath 'C:\Users\USER\.vscode\extensions\ms-vscode.powershell-1.10.2\sessions\PSES-VSCode-15988-744644' -FeatureFlags @()
1/7/2019 2:39:12 PM [NORMAL] - powershell.exe started, pid: 5284
1/7/2019 2:39:13 PM [NORMAL] - Language server started.
1/7/2019 2:39:13 PM [NORMAL] - {"languageServiceTransport":"NamedPipe","languageServicePipeName":"\\\\.\\pipe\\PSES_fcibqsfu.apc","debugServiceTransport":"NamedPipe","status":"started","debugServicePipeName":"\\\\.\\pipe\\PSES_zt1wz0hq.pdb"}
1/7/2019 2:39:13 PM [NORMAL] - Connecting to language service on pipe \\.\pipe\PSES_fcibqsfu.apc...
1/7/2019 2:39:13 PM [NORMAL] - Language service connected.
1/7/2019 2:42:09 PM [NORMAL] - powershell.exe terminated or terminal UI was closed

Extension version: 1.10.2 VS Code version: Code 1.30.1 (dea8705087adb1b5e5ae1d9123278e178656186a, 2018-12-18T18:12:07.165Z) OS version: Windows_NT x64 10.0.18309

System Info
Item Value
CPUs Intel® Core™ i7-6500U CPU @ 2.50GHz (4 x 2592)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 15.90GB (8.17GB free)
Process Argv
Screen Reader no
VM 0%

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 21 (1 by maintainers)

Most upvoted comments

This is a folding provider bug (that @KaylorDave is seeing) that I believe I have fixed in this PR. The relevant section of the log is:

       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
       at Microsoft.PowerShell.EditorServices.Workspace.GetFile(String filePath)
       at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.Fold(String documentUri)

The first zip file above is the same old Folding bug that should be fixed in the next release. The last two are new and associated with providing Comment Help:

    System.AggregateException: One or more errors occurred. (Could not find file 'C:\Users\kaylorw\untitled:Untitled-1'.) ---> System.IO.FileNotFoundException: Could not find file 'C:\Users\kaylorw\untitled:Untitled-1'.
       at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
       at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
       at Microsoft.PowerShell.EditorServices.Workspace.GetFile(String filePath)
       at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.HandleCommentHelpRequest(CommentHelpRequestParams requestParams, RequestContext`1 requestContext)

The fix should be easy. The workaround for now is the same as with the Folding bug, save an “untitled” file to disk as soon as possible.

BTW looks like another case where we should be using TryGetFile(). I should be able to knock this one out tonight.

I’m not seeing these crashes anymore since the update, seems resolved for me.

Thanks!

Seeing the description for PR @rkeithhill mentions, this may be the same problem I’m having - paste into an file - especially an unnamed file, and especially if syntactically bad , will causes powershell to terminate, but I have not found a reliable way to provoke it. Nor can I pin down which recent update changed matters but since mid December crashes have gone from almost-never, to every few minutes. Hoping that fix covers both and gets pushed soon,

I am also having this problem. Ever since Windows 10 upgraded from 1607 to 1803 some weeks back, PowerShell in VSCode crashes constantly. All I have to do is paste some text or type a few characters, wait a second or two and then I get pop-up “The PowerShell session has terminated due to an error, would you like to restart it?”.

Unlike the OP’s issue, my crashes aren’t related to O365 scripts.

ISE works without issues.

In output there is only one new line when the crashes occur. 1/10/2019 1:33:34 PM [NORMAL] - powershell.exe terminated or terminal UI was closed

The crashes are so frequent that this has pretty much made VSCode useless for me.

I’ve enabled verbose logging so the next time it happens I’ll have more for you.