Vscode-powershell: Cannot read property 'sendRequest' of undefined

Created on 30 Nov 2019  Â·  21Comments  Â·  Source: PowerShell/vscode-powershell

Hi,

My problem is whenever I try and format a Powershell file I get the message.

Cannot read property 'sendRequest' of undefined

Versions

  • VS Code: 1.40.0 (system setup)
  • OS: Windows 10 10.0.18362
  • Powershell Ext: v2019.11.0
  • PS Version: 5.1.18362.145

Code formatting works in the other file types I use. e.g. JSON, Go, XML.

I have removed the following directories and started with a clean config.

  • C:\Users\simon\AppData\Roaming\Code
  • C:\Users\simon.vscode
  • C:\Users\simon\.vscode

The only extensions I have installed are.

  • PowerShell
  • Remote - WSL

I have spent most of the morning googling for an answer but am getting no where.

Please let me know what information you need to investigate.

Thanks
Simon

Resolution-Duplicate

All 21 comments

Hi @simononebyte, are you using the PowerShell preview extension or the normal version?

If you are able to share your logs that would help us diagnose the issue.

Hi @rjmholt , everything is standard release, no previews. I have attached the log files created. Only thing that jumps out to me

EditorServices.log
Start-EditorServices-EditorServices.log
vscode-powershell.log

Only thing that jumps out to me is the error: Could not load file or assembly 'Newtonsoft.Json...

Thanks
Simon

Yes, this looks like the extension hasn't loaded properly for you; it needs Newtonsoft.Json to serialise messages.

Try removing the PowerShell extension, deleting the directory at ~/.vscode/extensions/ms-vscode.powershell-2019.11.0/ and then reinstalling the PowerShell extension.

If it persists after that, we should look at the result of gci -Recurse ~\.vscode\extensions\ms-vscode.powershell-2019.11.0\modules\PowerShellEditorServices\bin\ and possibly enable fusion logging to work out if the Newtonsoft DLL is there and why PSES isn't loading it on your machine.

I have the same issue for a week or so on my standard installation.

Try removing the PowerShell extension, deleting the directory at ~/.vscode/extensions/ms-vscode.powershell-2019.11.0/ and then reinstalling the PowerShell extension.

this didn't help. I have attached my fusion log and ~\.vscode\extensions\ms-vscode.powershell-2019.11.0\modules\PowerShellEditorServices\bin\
fusion-log.zip
bin.zip

Try removing the PowerShell extension, deleting the directory at ~/.vscode/extensions/ms-vscode.powershell-2019.11.0/ and then reinstalling the PowerShell extension.

@rjmholt That did work for me. Thanks very much.

@kpoxo6op. Hope you get to the bottom of your issue.

Well that smug feeling didn't last very long! The above worked on my work laptop but hasn't worked on my personal laptop. So attached are the outputs of the gci command and fusion logs.

gci.zip
Logs.zip

@simononebyte @kpoxo6op we recently published an update to our Preview Extension which has addressed a number of underlying architectural issues, would you mind giving it a try and letting us know if you are still hitting this issue?

Hi,

I will give it a try this evening and let you know.

Thanks
Simon

Simon Buckner Lead Technical Engineer
Tel: +44 (0) 203 189 2100 opt 5
www.onebyte.net
Really happy with us? Write a Google review here
Consider the environment before you print. Consider your inbox, and file, archive or delete
Bankside 300 Peachman Way, Broadland Business Park, Norwich, Norfolk, England NR7 0LB
Business Registered number: 05329402
This message contains confidential information and is intended only for the intended recipients. If you are not an intended
recipient you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you
have received this e-mail by mistake and delete this e-mail from your system.
From: Sydney Smith notifications@github.com
Sent: 17 December 2019 19:32
To: PowerShell/vscode-powershell vscode-powershell@noreply.github.com
Cc: Simon Buckner simon@onebyte.net; Mention mention@noreply.github.com
Subject: Re: [PowerShell/vscode-powershell] Cannot read property 'sendRequest' of undefined (#2336)

@simononebytehttps://github.com/simononebyte @kpoxo6ophttps://github.com/kpoxo6op we recently published an update to our Preview Extensionhttps://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell-Preview which has addressed a number of underlying architectural issues, would you mind giving it a try and letting us know if you are still hitting this issue?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/PowerShell/vscode-powershell/issues/2336?email_source=notifications&email_token=ACSGFWTBVF2C2SXRUXUFWLTQZESMNA5CNFSM4JTGDB5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHDWAIQ#issuecomment-566714402, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACSGFWWBQU4LNHBPYVXTK5TQZESMNANCNFSM4JTGDB5A.

Hi,
Installing the preview version on both my work and home machines seems to have fixed things. Not sure if it is relevant but the integrated powershell console is now loading to a working prompt whereas before it never returned an active prompt.

Simon

Glad to hear it. That experience will be available in the Stable extension next month so stay tuned for that!

@simononebyte @kpoxo6op we recently published an update to our Preview Extension which has addressed a number of underlying architectural issues, would you mind giving it a try and letting us know if you are still hitting this issue?

I am getting error "There is no formatter for 'powershell' files installed." with PowerShell Preview installed and PowerShell disabled.

@kpoxo6op looks like you are hitting the same issue as #1730 which was believed to be fixed in a previous release...does this still happen to you when you have a workspace loaded?

@SydneyhSmith

  • opened one of the PowerShell module folders
  • disabled PowerShell
  • installed PowerShell Preview
  • restarted VSCode
  • saved workspace as "Test1" to my Desktop
  • restarted VSCode
  • loaded workspace Test1
  • got 'powershell' files installed." again

also tried to open a few PowerShell other module folders and format .PS1, got the same error.

@kpoxo6op sounds like the extension is not started, are you getting any intellisense or other features of the extension?

@SydneyhSmith yes, looks like it's not starting for me at all. Just checked on my PC vs my teammate's PC.

VSCode on my teammate's PC is getting intellisense promts and can format .ps1 files.

VSCode on my PC is not getting intellisense promts and can not format .ps1 files.
Extension PowerShell is showing "Cannot read property 'sendRequest' of undefined".
Extension PowerShell Preview is showing "no formatter installed".

I had the same problem.

Using the preview fixed it.

[2020-01-19 15:39:39.851] [exthost] [error] [ms-vscode.powershell] provider FAILED [2020-01-19 15:39:39.852] [exthost] [error] TypeError: Cannot read property 'sendRequest' of undefined at PSDocumentFormattingEditProvider.sendDocumentFormatRequest (c:\Users\Velocet\.vscode\extensions\ms-vscode.powershell-2020.1.0\src\features\DocumentFormatter.ts:257:47) at PSDocumentFormattingEditProvider.provideDocumentRangeFormattingEdits (c:\Users\Velocet\.vscode\extensions\ms-vscode.powershell-2020.1.0\src\features\DocumentFormatter.ts:184:21) at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:578:504 at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:52:287 at new Promise (<anonymous>) at Object.t.asPromise (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:52:259) at D.provideDocumentRangeFormattingEdits (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:578:475) at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:596:829 at B._withAdapter (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:591:697) at B.$provideDocumentRangeFormattingEdits (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:596:807) at p._doInvokeHandler (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:663:275) at p._invokeHandler (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:662:971) at p._receiveRequest (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:661:588) at p._receiveOneMessage (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:660:468) at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:658:691 at l.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:46:893) at _.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:189:274) at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:820:285 at l.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:46:893) at _.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:189:274) at t.PersistentProtocol._receiveMessage (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:193:629) at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:190:824 at l.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:46:893) at p.acceptChunk (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:186:737) at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:186:89 at Socket.t (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:195:68) at Socket.emit (events.js:200:13) at addChunk (_stream_readable.js:294:12) at readableAddChunk (_stream_readable.js:275:11) at Socket.Readable.push (_stream_readable.js:210:10) at Pipe.onStreamRead (internal/stream_base_commons.js:166:17)

@kpoxo6op what version of Windows are you on? Win 10 1909?

@TylerLeonhardt Win 10 1909 Build 18363.535

@kpoxo6op it looks like you are having the same issue as #2417 could you please collate your information and add it as a comment there so we can narrow down the issue...thanks! It would also be helpful if you could provide a GIF of what you are seeing...thanks!

This issue has been marked as duplicate and has not had any activity for 1 day. It has been closed for housekeeping purposes.

thanks @TylerLeonhardt and @SydneyhSmith, the root cause for my case was setting "powershell.startAutomatically": false (facepalm)

Was this page helpful?
0 / 5 - 0 ratings