Open PrzemyslawKlys opened 4 years ago
Still a module problem, just a different module. Some module is getting auto loaded that doesn't play well at type load. Note that this will only occur in Windows PowerShell as PowerShell Core will swallow these exceptions and continue searching.
Well, that's a bummer. I believe a lot of my problems may be coming from something else then extension itself, but my problem is:
I'm pretty sure that all my hangings, stops of IntelliSense may be coming from outside of extension, and a lot of other people may be thinking that Code sucks because of it, when it's not entirely it's a fault. I'm having huge numbers of show stoppers in my case and I can imagine other people do as well but don't do any sort of reporting.
Well, that's a bummer. I believe a lot of my problems may be coming from something else then extension itself (...) I'm pretty sure that all my hangings, stops of IntelliSense may be coming from outside of extension, and a lot of other people may be thinking that Code sucks because of it, when it's not entirely it's a fault. I'm having huge numbers of show stoppers in my case and I can imagine other people do as well but don't do any sort of reporting.
I know right? I suspect the same but it's difficult to prove and at the end of the day no one really cares whose fault it is (rightfully).
There's a whole lot of things that crop up like this when you start doing more than the basics because of finicky engine API's. This extension sees it more than something like the ISE partially because it just does more things. Fortunately a lot of these finicky API's are getting fixed, just not back ported.
Basically a lot of these API's were under used (or not used at all) so a lot of bugs were missed. Once we started using them more, they get caught and fixed. That's great but it does mean older more final versions of PowerShell are gonna feel kinda bad because they're a bit rickety.
- tracking it - how do I know which module is offending in this case
Yeah it's a pain. Check out the assembly name and look around for a file that matches in your installed modules. You also might be able to find it doing something like this:
[AppDomain]::CurrentDomain.
GetAssemblies().
Where{ $_.GetReferencedAssemblies().Name -contains 'Full.Assembly.Name.Here' }.
ForEach{ $_.GetName() }
Unfortunately it's often referenced assemblies of referenced assemblies so it's difficult to track down.
- can Powershell extension "fix" it for 5.1 or are we doomed
Not cleanly :/ The problem is that it's the engine throwing really early into tab completion. Here's what happens:
TabExpansion2
is calledI have a script somewhere that manually repopulates the cache with big ol' piles of reflection. I'll see if I can dig it up but it's not a good solution generally because it's super expensive to run and in a lot of cases isn't actually needed. I used it a lot when I still had to live mostly in Windows PowerShell. It's tricky though because I often had to run it several times due to more assemblies loading and clearing the cache during the process of repopulating the cache... it's really unfortunate that that exception went uncaught for so long.
I'll see if I can dig it up but it's not a good solution generally because it's super expensive to run and in a lot of cases isn't actually needed
It may be, once other work is done, we could do something like detect an exception like this in tab completion somehow and have our own cache invalidation logic within PSES.
I know we chalk a lot of issues in the extension up to PowerShell itself being a difficult platform, and having worked on it for a while, it absolutely is (and not in obvious ways). BUT, as an editor/IDE we have to own the challenge of being robust, which is generally a case of shaving the yak to catch all the nasty little exceptions and details and work out what on earth we do with them.
It may be, once other work is done, we could do something like detect an exception like this in tab completion somehow and have our own cache invalidation logic within PSES.
Fair enough. And also looking at it again I'm remembering that it was really expensive because I wrote it in ~10 minutes as a stop gap. It can almost definitely be written in a noticeably more performant way:
NOTE: Actually invoking that requires this function from my profile and the PSLambda module installed.
I know we chalk a lot of issues in the extension up to PowerShell itself being a difficult platform, and having worked on it for a while, it absolutely is (and not in obvious ways). BUT, as an editor/IDE we have to own the challenge of being robust, which is generally a case of shaving the yak to catch all the nasty little exceptions and details and work out what on earth we do with them.
Yeah I agree. The user doesn't (and shouldn't have to) care where the problem really is, especially if it only surfaces with us. I tried to convey that above but I may have over explained the negative a little.
[AppDomain]::CurrentDomain.GetAssemblies().Where{ $_.GetReferencedAssemblies().Name -contains 'Microsoft.Data.Services.Client' }.ForEach{ $_.GetName() } | Format-Table Name, Version, CodeBase
Microsoft.Open.AzureAD16.Graph.Client 2.0.0.0 file:///C:/Users/przemyslaw.klys/Documents/WindowsPowerShell/Modules/AzureADPreview/2.0.2.62/Microsoft.Open.AzureAD16.Graph.Client.dll
Microsoft.Open.AzureADBeta.Graph.Client 2.0.0.0 file:///C:/Users/przemyslaw.klys/Documents/WindowsPowerShell/Modules/AzureADPreview/2.0.2.62/Microsoft.Open.AzureADBeta.Graph.Client.dll
Microsoft.Open.MS.GraphBeta.Client 2.0.0.0 file:///C:/Users/przemyslaw.klys/Documents/WindowsPowerShell/Modules/AzureADPreview/2.0.2.62/Microsoft.Open.MS.GraphBeta.Client.DLL
Microsoft.Online.Administration.Automation.PSModule 1.1.0.0 file:///C:/Program Files/WindowsPowerShell/Modules/MSOnline/1.1.183.57/Microsoft.Online.Administration.Automation.PSModule.dll
Microsoft.Azure.ActiveDirectory.GraphClient 2.1.1.0 file:///C:/Program Files/WindowsPowerShell/Modules/MSOnline/1.1.183.57/Microsoft.Azure.ActiveDirectory.GraphClient.dll
Thanks @SeeminglyScience - I tracked it to 2.0.2.62 old preview which I have installed (also newer ones). Deleted it and will see what happens. I guess I have to use some cleanup utility which will remove old modules that are available across computers.
I always assumed only newest is autoloader but seems it's not true. So need to be careful now :-)
I always assumed only newest is autoloader but seems it's not true
The first one on the module path is autoloaded. In your case, the module in your user module path precedes the ones in the shared path, so is loaded despite its lower version. Also note that when two versions of the same module occur under the same path (like 2.0.2.105 and 2.0.2.102 here), the newest wins.
Issue Description
I am experiencing a problem with... not being given parameter types. It works, works, works and randomly stops.
I had this problem before and it was solved in: https://github.com/PowerShell/vscode-powershell/issues/2743 by @SeeminglyScience pointing to a module problem. The difference being it didn't work at all back then, but now it's working fine just simply fails after a while.
I've used the same debug steps as in other thread and this time it's not about problems with that external helper module but some problems with DLL.
Is there anything I can do?
1598194129-afdfd4de-6452-4c44-a771-59ce3569b53b1598107482495.zip
Attached Logs
Follow the instructions in the README about capturing and sending logs.
Environment Information
Visual Studio Code
PowerShell Information
Visual Studio Code Extensions
Visual Studio Code Extensions(Click to Expand)
|Extension|Author|Version| |---|---|---| |better-toml|bungcip|0.3.2| |bracket-pair-colorizer-2|CoenraadS|0.2.0| |errorlens|usernamehw|3.2.0| |format-selection-as-html|adrianwilczynski|2.3.0| |github-linker|gimenete|0.2.3| |gitlens|eamodio|10.2.2| |line-endings|steditor|1.0.3| |markdown-all-in-one|yzhang|3.2.0| |material-icon-theme|PKief|4.2.0| |open-in-browser|techer|2.0.0| |powershell-preview|ms-vscode|2020.7.0| |project-manager|alefragnani|11.2.0| |run-in-powershell|tobysmith568|1.1.0| |vscode-markdownlint|DavidAnson|0.36.3| |vscode-pull-request-github|GitHub|0.19.0| |vscode-toggle-quotes|BriteSnow|0.3.3| |vscode-wakatime|WakaTime|4.0.0| |vscode-yaml|redhat|0.10.0| |xml|DotJoshJohnson|2.5.1|