PowerShell / vscode-powershell

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

EditorServices Crash - ERRORS caught while waiting for EditorServicesHost to complete execution #1492

Closed PrzemyslawKlys closed 6 years ago

PrzemyslawKlys commented 6 years ago

System Details

Name                           Value
----                           -----
PSVersion                      5.1.17738.1000
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17738.1000
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
Copy / paste the following commands into the PowerShell Integrated Console, and paste the output here:

PS C:\Users\pklys\OneDrive - Evotec\Support\GitHub\PSWinDocumentation> $pseditor.EditorServicesVersion
PS C:\Users\pklys\OneDrive - Evotec\Support\GitHub\PSWinDocumentation> code --list-extensions --show-versions
aaron-bond.better-comments@1.2.6
abusaidm.html-snippets@0.2.1
AlanWalk.markdown-toc@1.5.6
alefragnani.Bookmarks@9.0.3
azemoh.one-monokai@0.3.4
ban.spellright@2.5.30
batisteo.vscode-django@0.17.0
bierner.markdown-preview-github-styles@0.1.2
daiyy.quick-html-previewer@0.3.0
DavidAnson.vscode-markdownlint@0.20.0
DavidWang.ini-for-vscode@0.0.4
donjayamanne.githistory@0.4.2
donjayamanne.jupyter@1.1.4
donjayamanne.python-extension-pack@1.4.0
DotJoshJohnson.xml@2.3.2
eamodio.gitlens@8.5.5
emilast.LogFileHighlighter@2.4.0
emmanuelbeziat.vscode-great-icons@2.1.41
Equinusocio.vsc-material-theme@2.3.0
felixfbecker.php-debug@1.12.4
formulahendry.code-runner@0.9.4
gerane.Theme-dimmed-monokai@0.0.2
gharveymn.nightswitch@1.1.0
GrapeCity.gc-excelviewer@2.1.25
hdg.live-html-previewer@0.3.0
hnw.vscode-auto-open-markdown-preview@0.0.4
HookyQR.beautify@1.3.2
IBM.output-colorizer@0.1.2
ikappas.phpcs@1.0.5
ionutvmi.reg@0.0.2
JerryHong.autofilename@0.1.3
joaompinto.asciidoctor-vscode@0.15.0
johnpapa.winteriscoming@0.7.1
Kelvin.vscode-sshfs@1.9.2
kisstkondoros.vscode-codemetrics@1.17.1
KnisterPeter.vscode-github@0.30.0
magicstack.MagicPython@1.0.12
mariorodeghiero.vue-theme@1.0.9
mechatroner.rainbow-csv@0.4.2
mkloubert.vs-deploy@14.0.0
mkloubert.vscode-remote-workspace@0.32.1
ms-mssql.mssql@1.4.0
ms-python.python@2018.7.1
ms-vscode.csharp@1.15.2
ms-vscode.PowerShell@1.8.3
ms-vsliveshare.vsliveshare@0.3.535
ms-vsts.team@1.136.0
quicktype.quicktype@12.0.38
redhat.java@0.29.0
robertohuertasm.vscode-icons@7.25.0
Shan.code-settings-sync@3.0.0
stkb.rewrap@1.9.1
streetsidesoftware.code-spell-checker@1.6.10
streetsidesoftware.code-spell-checker-polish@1.0.0
TomasHubelbauer.zip-file-system@0.5.0
vangware.dark-plus-material@1.3.1
VisualStudioExptTeam.vscodeintellicode@1.0.3
vscjava.vscode-java-debug@0.11.0
vscjava.vscode-java-pack@0.3.0
vscjava.vscode-java-test@0.8.0
vscjava.vscode-maven@0.10.0
WakaTime.vscode-wakatime@1.2.3
wayou.vscode-todo-highlight@1.0.4
whizkydee.material-palenight-theme@1.9.3
wholroyd.jinja@0.0.8
xaver.clang-format@1.6.2
yzhang.markdown-all-in-one@1.6.0
zhuangtongfa.Material-theme@2.15.4
Zignd.html-css-class-completion@1.11.0
openssl config failed: error:02001003:system library:fopen:No such process
PS C:\Users\pklys\OneDrive - Evotec\Support\GitHub\PSWinDocumentation> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.17738.1000
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17738.1000
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

I am experiencing a problem with... Editor Services crashing.

#-- Waiting for EditorServicesHost to complete execution ---------------------
VERBOSE: ERRORS caught while waiting for EditorServicesHost to complete execution
VERBOSE: One or more errors occurred.
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at CallSite.Target(Closure , CallSite , Object )
VERBOSE: One or more errors occurred.
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at CallSite.Target(Closure , CallSite , Object )
One or more errors occurred.
VERBOSE: One or more errors occurred.
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at CallSite.Target(Closure , CallSite , Object )
One or more errors occurred.

Specified argument was out of the range of valid values.
Parameter name: Position 284:1 is outside of the line range of 1 to 283.
   at Microsoft.PowerShell.EditorServices.ScriptFile.ValidatePosition(Int32 line, Int32 column)
   at Microsoft.PowerShell.EditorServices.ScriptFile.ApplyChange(FileChange fileChange)
   at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.HandleDidChangeTextDocumentNotification(DidChangeTextDocumentParams textChangeParams, EventContext eventContext)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<>c__DisplayClass6_0`2.<SetEventHandler>b__0(Message eventMessage, MessageWriter messageWriter)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<DispatchMessage>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.<ListenForMessages>d__36.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
   at System.Threading.Tasks.Task.Execute()
PS>$global:?
True
**********************
Windows PowerShell transcript end
End time: 20180820172833
**********************

Attached Logs

Follow the instructions in the README about capturing and sending logs.

1534771635-da9828e6-52a6-47a2-a062-a301bcd324121534770956637.zip

rjmholt commented 6 years ago

@PrzemyslawKlys do you have a small reproducible scenario at all? What were doing when the crash happened?

PrzemyslawKlys commented 6 years ago

Unfortunately it doesn't happen a lot. It happend 3 times so far in 2 days.

I believe in last case it just happend. I was typing something in VSCode, maybe doing CTRL C+V and it simply crashed.

But it as well cane be related to those 2 things:

rjmholt commented 6 years ago

Understood.

I'm pretty certain it's a race condition.

I'll need to look into it as part of broader work on the extension (getting threading right generally), so the fix is unlikely to be simple or immediate.

PrzemyslawKlys commented 6 years ago

Happend again:


2018-08-20 21:35:34.378 [VERBOSE] C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageReader.cs: In method 'ReadMessage', line 123:
    Received Event 'textDocument/didChange'

2018-08-20 21:35:34.384 [VERBOSE] C:\PowerShellEditorServices\src\PowerShellEditorServices\Workspace\Workspace.cs: In method 'ResolveFilePath', line 378:
    Resolved path: c:\Users\pklys\OneDrive - Evotec\Support\GitHub\PSWriteWord\Publish\Manage-PSWriteWord.ps1

2018-08-20 21:35:34.388 [ERROR] C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\ProtocolEndpoint.cs: In method 'OnListenTaskCompleted', line 391:
    ProtocolEndpoint message loop terminated due to unhandled exception:

    System.AggregateException: One or more errors occurred. ---> System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    Parameter name: Position 15:1 is outside of the line range of 1 to 14.
       at Microsoft.PowerShell.EditorServices.ScriptFile.ValidatePosition(Int32 line, Int32 column)
       at Microsoft.PowerShell.EditorServices.ScriptFile.ApplyChange(FileChange fileChange)
       at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.HandleDidChangeTextDocumentNotification(DidChangeTextDocumentParams textChangeParams, EventContext eventContext)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<>c__DisplayClass6_0`2.<SetEventHandler>b__0(Message eventMessage, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<DispatchMessage>d__7.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.<ListenForMessages>d__36.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
       at System.Threading.Tasks.Task.Execute()
       --- End of inner exception stack trace ---
    ---> (Inner Exception #0) System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    Parameter name: Position 15:1 is outside of the line range of 1 to 14.
       at Microsoft.PowerShell.EditorServices.ScriptFile.ValidatePosition(Int32 line, Int32 column)
       at Microsoft.PowerShell.EditorServices.ScriptFile.ApplyChange(FileChange fileChange)
       at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.HandleDidChangeTextDocumentNotification(DidChangeTextDocumentParams textChangeParams, EventContext eventContext)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<>c__DisplayClass6_0`2.<SetEventHandler>b__0(Message eventMessage, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<DispatchMessage>d__7.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.<ListenForMessages>d__36.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
       at System.Threading.Tasks.Task.Execute()<---

2018-08-20 21:35:34.388 [ERROR] C:\PowerShellEditorServices\src\PowerShellEditorServices.Host\EditorServicesHost.cs: In method 'ProtocolEndpoint_UnhandledException', line 435:
    PowerShell Editor Services is terminating due to an unhandled exception, see previous logs for details.

Was just editing some code. Stopped, was looking at something else and noticed it crashed.

PrzemyslawKlys commented 6 years ago

And another one:

018-08-20 22:15:53.536 [DIAGNOSTIC] C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageReader.cs: In method 'ReadMessage', line 114:
    READ MESSAGE:

    {
      "jsonrpc": "2.0",
      "method": "textDocument/didChange",
      "params": {
        "textDocument": {
          "uri": "file:///c%3A/Users/pklys/OneDrive%20-%20Evotec/Support/GitHub/PSWriteWord/Publish/Manage-PSWriteWord.ps1",
          "version": 4
        },
        "contentChanges": [
          {
            "range": {
              "start": {
                "line": 14,
                "character": 0
              },
              "end": {
                "line": 16,
                "character": 0
              }
            },
            "rangeLength": 4,
            "text": ""
          }
        ]
      }
    }

2018-08-20 22:15:53.536 [VERBOSE] C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageReader.cs: In method 'ReadMessage', line 123:
    Received Event 'textDocument/didChange'

2018-08-20 22:15:53.544 [VERBOSE] C:\PowerShellEditorServices\src\PowerShellEditorServices\Workspace\Workspace.cs: In method 'ResolveFilePath', line 378:
    Resolved path: c:\Users\pklys\OneDrive - Evotec\Support\GitHub\PSWriteWord\Publish\Manage-PSWriteWord.ps1

2018-08-20 22:15:53.550 [ERROR] C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\ProtocolEndpoint.cs: In method 'OnListenTaskCompleted', line 391:
    ProtocolEndpoint message loop terminated due to unhandled exception:

    System.AggregateException: One or more errors occurred. ---> System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    Parameter name: Position 17:1 is outside of the line range of 1 to 16.
       at Microsoft.PowerShell.EditorServices.ScriptFile.ValidatePosition(Int32 line, Int32 column)
       at Microsoft.PowerShell.EditorServices.ScriptFile.ApplyChange(FileChange fileChange)
       at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.HandleDidChangeTextDocumentNotification(DidChangeTextDocumentParams textChangeParams, EventContext eventContext)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<>c__DisplayClass6_0`2.<SetEventHandler>b__0(Message eventMessage, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<DispatchMessage>d__7.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.<ListenForMessages>d__36.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
       at System.Threading.Tasks.Task.Execute()
       --- End of inner exception stack trace ---
    ---> (Inner Exception #0) System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    Parameter name: Position 17:1 is outside of the line range of 1 to 16.
       at Microsoft.PowerShell.EditorServices.ScriptFile.ValidatePosition(Int32 line, Int32 column)
       at Microsoft.PowerShell.EditorServices.ScriptFile.ApplyChange(FileChange fileChange)
       at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.HandleDidChangeTextDocumentNotification(DidChangeTextDocumentParams textChangeParams, EventContext eventContext)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<>c__DisplayClass6_0`2.<SetEventHandler>b__0(Message eventMessage, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<DispatchMessage>d__7.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.<ListenForMessages>d__36.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
       at System.Threading.Tasks.Task.Execute()<---

2018-08-20 22:15:53.551 [ERROR] C:\PowerShellEditorServices\src\PowerShellEditorServices.Host\EditorServicesHost.cs: In method 'ProtocolEndpoint_UnhandledException', line 435:
    PowerShell Editor Services is terminating due to an unhandled exception, see previous logs for details.

Let me know if you want me to keep on adding as i encounter those or it's enough for now (maybe you need full log as well). I guess without reproducible case it's not gonna be easy/nessecary. One more thing that I do common is having 3+ VS Code windows with 3 different projects open at all times.

rjmholt commented 6 years ago

This information seems like enough to go on for now -- it looks like the file offset in VSCode is not synchronised with the actual file.

It's the kind of thing that may be difficult to implement correctly, but we should still catch the error and just move on.

csandfeld commented 6 years ago

I am experiencing what I believe to be the same issue, several times a day. I think the problem first occured after the powershell extension was updated to version 1.8.3 (however that may be coincidental).

Logs and environment info attached below

Attached Logs

EditorServices.log

2018-08-23 16:10:14.519 [NORMAL] C:\PowerShellEditorServices\src\PowerShellEditorServices.Host\EditorServicesHost.cs: In method 'StartLogging', line 160:
    PowerShell Editor Services Host v1.8.3.0 starting (pid 28868)...

      Host application details:

        Name:      Visual Studio Code Host
        ProfileId: Microsoft.VSCode
        Version:   1.8.3
        Arch:      64-bit

      Operating system details:

        Version: Microsoft Windows NT 10.0.17134.0
        Arch:    64-bit

2018-08-23 16:10:14.552 [NORMAL] C:\PowerShellEditorServices\src\PowerShellEditorServices.Host\EditorServicesHost.cs: In method 'StartLanguageService', line 194:
    Language service started, type = NamedPipe, endpoint = PSES_25316eba-2bfa-496e-b0f8-b9a7efd2fd1c

2018-08-23 16:10:14.560 [NORMAL] C:\PowerShellEditorServices\src\PowerShellEditorServices.Host\EditorServicesHost.cs: In method 'StartDebugService', line 266:
    Debug service started, type = NamedPipe, endpoint = PSES_1033ab05-bcb3-4002-afd2-42ae3bdc224b

2018-08-23 16:10:15.139 [NORMAL] C:\PowerShellEditorServices\src\PowerShellEditorServices\Session\PowerShellContext.cs: In method 'Initialize', line 220:
    PowerShell runtime version: 5.1.17134.228, edition: Desktop

2018-08-23 16:10:16.202 [NORMAL] C:\PowerShellEditorServices\src\PowerShellEditorServices.VSCode\ComponentRegistration.cs: In method 'Register', line 36:
    PowerShell Editor Services VS Code module loaded.

2018-08-23 16:10:27.621 [NORMAL] C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\Server\DebugAdapter.cs: In method 'Stop', line 167:
    Debug adapter is shutting down...

2018-08-23 16:10:27.621 [NORMAL] C:\PowerShellEditorServices\src\PowerShellEditorServices.Host\EditorServicesHost.cs: In method 'OnDebugServiceClientConnect', line 312:
    Previous debug session ended, restarting debug service listener...

2018-08-23 16:10:36.822 [NORMAL] C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\Server\DebugAdapter.cs: In method 'Stop', line 167:
    Debug adapter is shutting down...

2018-08-23 16:10:36.822 [NORMAL] C:\PowerShellEditorServices\src\PowerShellEditorServices.Host\EditorServicesHost.cs: In method 'OnDebugServiceClientConnect', line 312:
    Previous debug session ended, restarting debug service listener...

2018-08-23 16:10:41.766 [NORMAL] C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\Server\DebugAdapter.cs: In method 'Stop', line 167:
    Debug adapter is shutting down...

2018-08-23 16:10:41.766 [NORMAL] C:\PowerShellEditorServices\src\PowerShellEditorServices.Host\EditorServicesHost.cs: In method 'OnDebugServiceClientConnect', line 312:
    Previous debug session ended, restarting debug service listener...

2018-08-23 16:10:47.118 [NORMAL] C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\Server\DebugAdapter.cs: In method 'Stop', line 167:
    Debug adapter is shutting down...

2018-08-23 16:10:47.118 [NORMAL] C:\PowerShellEditorServices\src\PowerShellEditorServices.Host\EditorServicesHost.cs: In method 'OnDebugServiceClientConnect', line 312:
    Previous debug session ended, restarting debug service listener...

2018-08-23 16:10:50.858 [NORMAL] C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\Server\DebugAdapter.cs: In method 'Stop', line 167:
    Debug adapter is shutting down...

2018-08-23 16:10:50.858 [NORMAL] C:\PowerShellEditorServices\src\PowerShellEditorServices.Host\EditorServicesHost.cs: In method 'OnDebugServiceClientConnect', line 312:
    Previous debug session ended, restarting debug service listener...

2018-08-23 16:10:53.354 [NORMAL] C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\Server\DebugAdapter.cs: In method 'Stop', line 167:
    Debug adapter is shutting down...

2018-08-23 16:10:53.354 [NORMAL] C:\PowerShellEditorServices\src\PowerShellEditorServices.Host\EditorServicesHost.cs: In method 'OnDebugServiceClientConnect', line 312:
    Previous debug session ended, restarting debug service listener...

2018-08-23 16:10:58.637 [NORMAL] C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\Server\DebugAdapter.cs: In method 'Stop', line 167:
    Debug adapter is shutting down...

2018-08-23 16:10:58.637 [NORMAL] C:\PowerShellEditorServices\src\PowerShellEditorServices.Host\EditorServicesHost.cs: In method 'OnDebugServiceClientConnect', line 312:
    Previous debug session ended, restarting debug service listener...

2018-08-23 16:11:04.457 [ERROR] C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\ProtocolEndpoint.cs: In method 'OnListenTaskCompleted', line 391:
    ProtocolEndpoint message loop terminated due to unhandled exception:

    System.AggregateException: One or more errors occurred. ---> System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    Parameter name: Position 59:1 is outside of the line range of 1 to 58.
       at Microsoft.PowerShell.EditorServices.ScriptFile.ValidatePosition(Int32 line, Int32 column)
       at Microsoft.PowerShell.EditorServices.ScriptFile.ApplyChange(FileChange fileChange)
       at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.HandleDidChangeTextDocumentNotification(DidChangeTextDocumentParams textChangeParams, EventContext eventContext)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<>c__DisplayClass6_0`2.<SetEventHandler>b__0(Message eventMessage, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<DispatchMessage>d__7.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.<ListenForMessages>d__36.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
       at System.Threading.Tasks.Task.Execute()
       --- End of inner exception stack trace ---
    ---> (Inner Exception #0) System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    Parameter name: Position 59:1 is outside of the line range of 1 to 58.
       at Microsoft.PowerShell.EditorServices.ScriptFile.ValidatePosition(Int32 line, Int32 column)
       at Microsoft.PowerShell.EditorServices.ScriptFile.ApplyChange(FileChange fileChange)
       at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.HandleDidChangeTextDocumentNotification(DidChangeTextDocumentParams textChangeParams, EventContext eventContext)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<>c__DisplayClass6_0`2.<SetEventHandler>b__0(Message eventMessage, MessageWriter messageWriter)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<DispatchMessage>d__7.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.<ListenForMessages>d__36.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
       at System.Threading.Tasks.Task.Execute()<---

2018-08-23 16:11:04.458 [ERROR] C:\PowerShellEditorServices\src\PowerShellEditorServices.Host\EditorServicesHost.cs: In method 'ProtocolEndpoint_UnhandledException', line 435:
    PowerShell Editor Services is terminating due to an unhandled exception, see previous logs for details.

vscode-powershell.log

8/23/2018 4:10:13 PM [NORMAL] - Language server starting --
8/23/2018 4:10:13 PM [NORMAL] -     exe: C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
8/23/2018 4:10:13 PM [NORMAL] -     args: C:\Users\chsa\.vscode\extensions\ms-vscode.powershell-1.8.3\modules\PowerShellEditorServices\Start-EditorServices.ps1 -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '1.8.3'-AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'C:\Users\chsa\.vscode\extensions\ms-vscode.powershell-1.8.3\modules'-EnableConsoleRepl -LogLevel 'Normal' -LogPath 'C:\Users\chsa\.vscode\extensions\ms-vscode.powershell-1.8.3\logs\1535033413-5f36e452-ea75-4bf0-bd08-482fc038060c1534926153176\EditorServices.log' -SessionDetailsPath 'C:\Users\chsa\.vscode\extensions\ms-vscode.powershell-1.8.3\sessions\PSES-VSCode-7796-818062' -FeatureFlags @()
8/23/2018 4:10:13 PM [NORMAL] - powershell.exe started, pid: 28868
8/23/2018 4:10:15 PM [NORMAL] - Language server started.
8/23/2018 4:10:15 PM [NORMAL] - Language service connected.
8/23/2018 4:10:15 PM [NORMAL] - {"status":"started","debugServiceTransport":"NamedPipe","languageServiceTransport":"NamedPipe","debugServicePipeName":"\\\\.\\pipe\\PSES_1033ab05-bcb3-4002-afd2-42ae3bdc224b","languageServicePipeName":"\\\\.\\pipe\\PSES_25316eba-2bfa-496e-b0f8-b9a7efd2fd1c"}
8/23/2018 4:10:15 PM [NORMAL] - Connecting to language service on pipe \\.\pipe\PSES_25316eba-2bfa-496e-b0f8-b9a7efd2fd1c...
8/23/2018 4:11:07 PM [NORMAL] - powershell.exe terminated or terminal UI was closed

Environment Information

Visual Studio Code

Name Version
Operating System Windows_NT x64 10.0.17134
VSCode 1.26.1
PowerShell Extension Version 1.8.3

PowerShell Information

Name Value
PSVersion 5.1.17134.228
PSEdition Desktop
PSCompatibleVersions 1.0 2.0 3.0 4.0 5.0 5.1.17134.228
BuildVersion 10.0.17134.228
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand) |Extension|Author|Version| |---|---|---| |code-settings-sync|Shan|3.0.0| |csharp|ms-vscode|1.15.2| |gc-excelviewer|GrapeCity|2.1.26| |gitlens|eamodio|8.5.6| |markdown-preview-github-styles|bierner|0.1.2| |Material-theme|zhuangtongfa|2.15.4| |nord-visual-studio-code|arcticicestudio|0.6.0| |PowerShell|ms-vscode|1.8.3| |rainbow-csv|mechatroner|0.4.2| |team|ms-vsts|1.136.0| |theme-sapphire|Tyriar|0.7.0| |vscode-icontheme-nomo-dark|be5invis|1.3.6| |vscode-markdownlint|DavidAnson|0.20.0| |vscode-theme-onedark|akamud|2.1.0|;
csandfeld commented 6 years ago

Let me know if you want me to try reproducing with verbose logging enabled.

rjmholt commented 6 years ago

Hi @csandfeld, I think the logging has identified where in the code the issue is, but won't help us identify why.

Can you describe anything about how you were modifying the script when the extension crashed?

csandfeld commented 6 years ago

Hi @rjmholt

I ran into this issue several times today, while testing some enums, classes, functions, and C# code (with Add-Type). I loaded a file holding the enums and classes, and a number of files each holding a function, into the active session using F5 (so running the debugger, but without doing any actual debugging). Then while typing a variable name ($whatever) in some test code, it would crash. Did that several times in a row.

rjmholt commented 6 years ago

The variable name was at the end of the file right? Was the file a new untitled file? Or a modification of one changed on the filesystem?

rjmholt commented 6 years ago

Ok, I think I've got this one fixed

csandfeld commented 6 years ago

@rjmholt: Yes, the edit was at or towards the end of the file (there may or may not have been some line breaks after), and it was a modification of an existing file.