Skip to content

Start-EditorServices.ps1 terminates on first request when started from Emacs (eglot) #2142

Closed
@macmacy

Description

@macmacy

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with PowerShell Editor Services itself and does not reproduce in a standalone PowerShell instance, and is not an issue with my editor.
  • I have verified that I am using the latest version of PowerShell Editor Services.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

I use Emacs+eglot with other language servers: OmniSharp, pyright, clangd, but cannot make it work with PowerShellEditorServices. The services command starts but exists after a while. Last message in log is Could not write to output handler, perhaps serialization failed?.

PowerShell Version

PS > $PSVersionTable

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

Editor Version

GNU Emacs 29.1 (build 2, x86_64-w64-mingw32) of 2023-08-02

PowerShell Editor Services Version

3.17.0 (latest)

Steps to Reproduce

I have PSES configured in .emacs like that:

(add-to-list
 'eglot-server-programs
 `(powershell-mode
       . ("pwsh" "-NoLogo" "-NoProfile" "-Command" , "c:/bin/PowerShellEditorServices/PowerShellEditorServices/Start-EditorServices.ps1"
          "-HostName" "Emacs" "-HostProfileId" "Emacs" "-HostVersion" "1.0.0"
          "-BundledModulesPath", "c:/bin/PowerShellEditorServices"
          "-LogPath" ,"c:/users/mmaczynski/AppData/Roaming/.pses-session/logs.log" "-LogLevel" "Diagnostic"
          "-SessionDetailsPath" ,"c:/users/mmaczynski/AppData/Roaming/.pses-session/session.json"
          "-Stdio")))

(add-hook 'powershell-mode 'eglot-ensure)

When I load .ps1 file, or execute M-x eglot when in powershell-mode, the Start-EditorServices is started but exists after a while, logging the following in session log file:

2024-02-28 14:18:59.973 +01:00 [VRB] Could not write to output handler, perhaps serialization failed?
System.Threading.Channels.ChannelClosedException: The channel has been closed.
   at System.Threading.Channels.AsyncOperation`1.GetResult(Int16 token)
   at OmniSharp.Extensions.JsonRpc.OutputHandler.ProcessOutputStream(CancellationToken cancellationToken)

I guess the server process exits on my first attempt to edit a file e.g. starting to type "Get-" or executing M-x eglot-rename

Visuals

No response

Logs

log files from PSES session directory:
logs.log
StartEditorServices.log

The content of Emacs eglot events buffer:
eglotlog.txt

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions