Skip to content

Timing issue in LanguageServer initialization #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gerane opened this issue May 13, 2016 · 28 comments
Closed

Timing issue in LanguageServer initialization #221

gerane opened this issue May 13, 2016 · 28 comments
Labels
Issue-Bug A bug to squash.
Milestone

Comments

@gerane
Copy link
Contributor

gerane commented May 13, 2016

After updating it appears PowerShellEditorServices is not properly starting.

I am getting the following error.

"No Handler found for the command: 'PowerShell.RunSelection'. An etension might be missing an activation event."

Tried restarts and a reboot. Will try reinstalling the extension next.

@gerane
Copy link
Contributor Author

gerane commented May 13, 2016

hmm, still present after a reinstall.

@rkeithhill
Copy link
Contributor

I can't repro this. Are you on VSCode 1.1.0 or an Insider's or Alpha build of VSCode?

@daviwil
Copy link
Contributor

daviwil commented May 13, 2016

I think he told me on Twitter that he's using the Insider build. Usually I see this error when PSES crashes at startup but it started up fine for him when he launched it directly. Might be something wonky with the extension code. I haven't been able to repro it either though.

@gerane
Copy link
Contributor Author

gerane commented May 13, 2016

The Editor Services is actually running, but f8 is totally broken. Intellisense is working, but f8 gives that error. I just updated my main desktop and seeing the same issue.

@gerane
Copy link
Contributor Author

gerane commented May 13, 2016

I'm on 1.1.0 insider

@gerane
Copy link
Contributor Author

gerane commented May 13, 2016

I restarted my desktop and it started working, but i've restarted my laptop VM a few times and still seeing the issue. I will see what I can figure out.

@gerane
Copy link
Contributor Author

gerane commented May 13, 2016

Here is what I am seeing in the console. That is the only error. When i use f8 and it errors, it doesn't output anything to the editorservices logs with verbose enabled.

workbench.main.js:117 Cannot read property 'getActiveEditor' of undefined: TypeError: Cannot read property 'getActiveEditor' of undefined
    at t.getActiveEditorInput (file:///C:/Program Files (x86)/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.main.js:101:19916)
    at e.getActiveEditorInput (file:///C:/Program Files (x86)/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.main.js:94:11666)
    at t.getFilePath (file:///C:/Program Files (x86)/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.main.js:82:9120)
    at t.Object.defineProperty.get [as file] (file:///C:/Program Files (x86)/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.main.js:82:8609)
    at file:///C:/Program Files (x86)/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.main.js:23:4134
    at String.replace (native)
    at t.e.__resolveString (file:///C:/Program Files (x86)/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.main.js:23:4103)
    at t.e.resolveAny (file:///C:/Program Files (x86)/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.main.js:23:3923)
    at file:///C:/Program Files (x86)/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.main.js:103:7306
    at Array.forEach (native)e.onUnexpectedError @ workbench.main.js:117
workbench.main.js:31 WARNING: Promise with no error callback:2

@gerane
Copy link
Contributor Author

gerane commented May 13, 2016

Here is one thing i've noticed. On my desktop, when it wasn't working I placed $psEditor in a script and ran it in the debugger. It was null. The same happens right now on my laptop that f8 is broken on.

Now that my desktop is working, $psEditor properly returns an object.

@daviwil
Copy link
Contributor

daviwil commented May 13, 2016

Huh... Interesting. I wonder if they changed the API? Have you tried in non-Insider VS Code on your VM?

@gerane
Copy link
Contributor Author

gerane commented May 13, 2016

Well, I think something is hanging. If I reload the editor on my desktop, and execute f8 right as it comes back up, I get that error. If I wait a couple seconds and then try it again, it works. It makes me think the editor services are not fully loading or getting partially hung up or something.

I will go download the Normal one and give that a try after lunch.

@daviwil
Copy link
Contributor

daviwil commented May 13, 2016

Yeah, it takes a couple seconds before PSES is fully initialized. Maybe on your VM it just takes a bit longer and it eventually works?

@gerane
Copy link
Contributor Author

gerane commented May 13, 2016

Nope, never loads.

I just finished installing the non-insider version and it is working in it. I will use it on my laptop for the time being until this get figured out. Let me know if there are any sort of tests or things you'd like me to try.

@daviwil
Copy link
Contributor

daviwil commented May 13, 2016

OK maybe the Insider build has broken it somehow, I'll take a look there.

@gerane
Copy link
Contributor Author

gerane commented May 13, 2016

Well, it eventually started working on my Desktop with Insider. I am not sure what it was that made it start working on my Desktop though.

@lucdekens
Copy link

For the record, I'm on Windows 10 build 10586, no insider build, and I experienced this as well.
After a couple of restarts, it started working again.
Anything I can do when it happens to help analyse the issue?

@daviwil
Copy link
Contributor

daviwil commented May 15, 2016

I've got a pretty clear picture of what's happening now. There appears to be a timing issue that's causing the language server's initialization to not complete. This causes the error you see and the subsequent lack of IntelliSense. Will get an update shipped this week to resolve this issue.

Related bug: PowerShell/vscode-powershell#183

@daviwil daviwil changed the title No Handler found for the command: 'PowerShell.RunSelection'. Timing issue in LanguageServer initialization May 15, 2016
@gpuido
Copy link

gpuido commented May 15, 2016

Same here, if I open a folder with about a 100 files, the service is rarely available.
But if I run vscode on just a file it's always available.
the profile.ps1 is never executed so It's easy to check availability with a Write-Host "Profile loaded" in it.

@daviwil
Copy link
Contributor

daviwil commented May 15, 2016

Interesting... The number of files in the folder shouldn't have a direct impact on the initial loading sequence. I might need to see if there's something happening there that I didn't expect.

@gpuido
Copy link

gpuido commented May 15, 2016

Also, if the git diff markers (red & green lines next to the line numbers column) appear then the profile is never loaded.

@gpuido
Copy link

gpuido commented May 15, 2016

I mean, if the git diff markers shows before the profile is loaded then it never will.

@amakhn
Copy link

amakhn commented May 16, 2016

Guys, any workaround?

@daviwil
Copy link
Contributor

daviwil commented May 16, 2016

There isn't one unfortunately since it's caused by how long the language server startup takes. I'll have a fix out in a day or two.

@daviwil daviwil added this to the 0.6.1 milestone May 16, 2016
@daviwil daviwil added the Issue-Bug A bug to squash. label May 16, 2016
daviwil added a commit that referenced this issue May 16, 2016
Fix #221: Occasional init hang in LanguageServer
@daviwil
Copy link
Contributor

daviwil commented May 16, 2016

Fix was pretty simple. I'll see if I can get the update out today!

@daviwil
Copy link
Contributor

daviwil commented May 16, 2016

Just shipped the 0.6.1 update, let me know if things are working right for you now!

@amakhn
Copy link

amakhn commented May 17, 2016

Works now! Brilliant! Many thanks!

@daviwil
Copy link
Contributor

daviwil commented May 17, 2016

Glad to hear it!

@KushGoswami
Copy link

Hello, I am having same issue with VS Code, I am on VS code version 1.1.1 and I am using Windows 7 and Power shell version 2.0 , Is it not supported on Win 7 with PS 2.0 ??

@rkeithhill
Copy link
Contributor

The extension supports PowerShell v3 and higher. V2 is not supported. V5 is available for Windows 7. I'd recommend that if you can update. Where I work we updated all our Windows 7 machines to at least V4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash.
Projects
None yet
Development

No branches or pull requests

7 participants