Skip to content

Session menu fails to open when PowerShell extension is starting #2906

Closed
@GaelGirodon

Description

@GaelGirodon

System Details

System Details Output
### VSCode version: 1.48.1 3dd905126b34dcd4de81fa624eb3a8cbe7485f13 x64

### VSCode extensions:
bierner.markdown-mermaid@1.8.1
DavidAnson.vscode-markdownlint@0.36.3      
EditorConfig.EditorConfig@0.15.1
emmanuelbeziat.vscode-great-icons@2.1.47   
ms-vscode.powershell@2020.6.0
streetsidesoftware.code-spell-checker@1.9.0
yzhang.markdown-all-in-one@3.2.0


### PSES version:

### PowerShell version:

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

Issue Description

I am experiencing a problem with the PowerShell session menu during extension loading.

Expected Behaviour

Clicking on the button 🔄 Starting PowerShell (at the bottom-right) should do nothing (if the extension is not ready) or should open the PowerShell session menu.

Actual Behaviour

The PowerShell session menu fails to open and the following error notification is displayed:

Running the contributed command: 'PowerShell.ShowSessionMenu' failed.

Note: with PowerShellGet and PackageManagement up-to-date, if I wait for the extension to fully load, 🔄 Starting PowerShell button is replaced by the PowerShell version (e.g. [>] 5.1) and the session menu can now be opened.

Attached Logs (and some further investigation)

The following error message is logged (Extension Host):

[2020-08-22 14:53:14.183] [exthost] [error] TypeError: Cannot read property 'displayVersion' of undefined
	at SessionManager.showSessionMenu (c:\Users\xxxx\.vscode\extensions\ms-vscode.powershell-2020.6.0\out\src\session.js:520:55)
	at c:\Users\xxxx\.vscode\extensions\ms-vscode.powershell-2020.6.0\out\src\session.js:303:91
	at _executeContributedCommand (c:\Users\xxxx\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:642:374)
	[...]

When I debug some values in session.js (showSessionMenu method), I get this:

  • availablePowerShellExes (L504): [{"exePath":"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe","displayName":"Windows PowerShell (x64)","knownToExist":true},{"exePath":"C:\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe","displayName":"Windows PowerShell (x86)","knownToExist":true}]
  • this.PowerShellExeDetails (L514): {"exePath":"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe","displayName":"Windows PowerShell (x64)","knownToExist":true}
  • currentPowerShellExe (L514): undefined
  • this.versionDetails (L514): undefined

this.versionDetails.displayVersion (L516) logically fails and throws the previous TypeError.

The following modification (L512) seems to fix the issue (and makes sense to me):

  const currentPowerShellExe = availablePowerShellExes
-                     .find((item) => item.displayName.toLowerCase() === this.PowerShellExeDetails.displayName);
+                     .find((item) => item.displayName.toLowerCase() === this.PowerShellExeDetails.displayName.toLowerCase());

With this modification, the first value of availablePowerShellExes is now assigned to currentPowerShellExe and the following ternary condition assigns currentPowerShellExe.displayName to powerShellSessionName without throwing the previous error.

This proposal may not be the right one. You may even consider that this issue is not really valid as the session menu succeeds to open when the extension is fully started. Maybe that a click on the button should not call the ShowSessionMenu command while the extension is loading?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions