Skip to content

Using -EnableConsoleRepl freezes the debug session until user input is received #2164

Open
@TheLeoP

Description

@TheLeoP

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

Starting the debugging service on an external terminal with both the -EnableConsoleRepl and the -DebugServiceOnly flags and then attaching to it via nvim-dap using the following adapter:

dap.adapters.powershell = {
  type = "pipe",
  pipe = "<some-harcoded-temp-path-on-unix-or-named-pipe-on-windows>",
}

and the following config:

dap.configurations.ps1 = {
  {
    name = "PowerShell: Launch Current File",
    type = "powershell",
    request = "launch",
    script = "${file}",
  },
}

Results in the debugger session correctly starting and the Integrated Terminal being displayed, but the current script isn't launched right away.

If then the enter key is pressed while inside of the Integrated Terminal, something like the following is shown:

PS /home/luis>
PS /home/luis> . '/home/luis/neovim/a.ps1'

The first line is the empty line where the user pressed the enter key. The second line is the script launched by Powershell Editor Services (only launched after the user issued an empty command).

The first breakpoint is hit inside of the script

The debugger is told to continue until the next breakpoint, nothing happens. The user has to, once again, issue an empty command before the debugger stops before the next breakpoint.

Notes:

  • the thins happens when using the languageService and sending an eval request. The request isn't processed until an empty command is issued by the user.
  • the same bug can be found on Windows and Linux.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Ubuntu 22.04.4 LTS
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Editor Version

NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info

PowerShell Editor Services Version

Major  Minor  Build  Revision
-----  -----  -----  --------
3      20     1      0

Steps to Reproduce

  1. pwsh -NoProfile -File /path/to/powershell-editor-services/PowerShellEditorServices/Start-EditorServices.ps1 -HostName nvim -HostProfileId Neovim -HostVersion 1.0.0 -LogPath /path/to/powershell_es.log -LogLevel Normal -BundledModulesPath /path/to/powershell-editor-services -EnableConsoleRepl -SessionDetailsPath /path/to/powershell_es.session.json -DebugServiceOnly <some-harcoded-temp-path-on-unix-or-named-pipe-on-windows>
  2. nvim example.ps1 (example.ps1 must contain any powershell code like some write-host commands) using the config described in the summary (I can provide a minimal.lua config if needed)
  3. Set a couple of breakpoints using :lua require'dap'.toggle_breakpoint()
  4. :lua require'dap'.continue()
  5. The terminal where the debug services was started will show the Integrated Terminal, the current script won't be launched and no breakpoint will be hit.
  6. Type the enter key on the Integrated Terminal (issuing an empty command)
  7. Now the script will be launched and the first breakpoint will be hit.

Visuals

No response

Logs

PowerShellEditorServices-100695.log
StartEditorServices-100695.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugA bug to squash.Needs: TriageMaintainer attention needed!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions