Skip to content

workspace/didChangeConfiguration: InvalidOperationException: An attempt was made to transition a task to a final state when it had already completed. #1495

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
dkattan opened this issue Jun 6, 2021 · 9 comments · Fixed by #1500
Assignees
Labels

Comments

@dkattan
Copy link
Contributor

dkattan commented Jun 6, 2021

Consider using TrySetResult to prevent this exception when the editor is re-initialized or sends a workspace/didChangeConfiguration request

@rjmholt

@ghost ghost added the Needs: Triage Maintainer attention needed! label Jun 6, 2021
@dkattan
Copy link
Contributor Author

dkattan commented Jun 6, 2021

Also consider checking that incomingSettings.Powershell isn't null before using it in ConfigurationHandler.SendFeatureChangesTelemetry:

if (incomingSettings.Powershell.ScriptAnalysis.Enable == false &&

The MonacoLanguageClient sends an empty settings object along with workspace/didChangeConfiguration and it throws an exception.

{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{}}}

@TylerLeonhardt

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Jun 6, 2021
@andyleejordan andyleejordan added Area-Language Server Issue-Bug A bug to squash. and removed Needs: Maintainer Attention Maintainer attention needed! Needs: Triage Maintainer attention needed! labels Jun 14, 2021
@andyleejordan andyleejordan self-assigned this Jun 14, 2021
@andyleejordan
Copy link
Member

I see two different bugs here in one issue, but will get them addressed.

@dkattan
Copy link
Contributor Author

dkattan commented Jun 14, 2021

I included both in the same issue since the repro steps are the same for both.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Jun 14, 2021
@andyleejordan andyleejordan removed the Needs: Maintainer Attention Maintainer attention needed! label Jun 14, 2021
@andyleejordan
Copy link
Member

@rjmholt Should we consider changing all uses of SetResult to TrySetResult? When do we actually ever want the server to crash?

@andyleejordan andyleejordan linked a pull request Jun 15, 2021 that will close this issue
@ghost ghost added the Status: In PR label Jun 15, 2021
@rjmholt
Copy link
Contributor

rjmholt commented Jun 16, 2021

When do we actually ever want the server to crash?

Just while I think of it, there's an answer to this: when we're debugging it. SetResult() crashing is useful to verify that a result is set exactly once under things like concurrent conditions (since otherwise subtler bugs may be occurring). When we actually stabilise a feature using SetResult(), it should probably use TrySetResult().

@dkattan
Copy link
Contributor Author

dkattan commented Jun 16, 2021

When do we actually ever want the server to crash?

Just while I think of it, there's an answer to this: when we're debugging it. SetResult() crashing is useful to verify that a result is set exactly once under things like concurrent conditions (since otherwise subtler bugs may be occurring). When we actually stabilise a feature using SetResult(), it should probably use TrySetResult().

To be fair, that's how I found this bug. But rather than letting it crash, why not write a warning so that it shows up in the console? For my use case, it is normal for it to not be able to set these values until Monaco gets around to sending the didChangeConfiguration message.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Jun 16, 2021
@ghost ghost added Status: Fixed and removed Status: In PR labels Jun 16, 2021
@andyleejordan
Copy link
Member

I wonder if this is somehow related to how the extension would fail when the OmniSharp race condition was present. The race prevented its didChangeConfiguration from reaching the server, causing it to never start. Manually triggering a second didChangeConfiguration would "fix" it. 🤔

@andyleejordan andyleejordan removed the Needs: Maintainer Attention Maintainer attention needed! label Jun 16, 2021
@dkattan
Copy link
Contributor Author

dkattan commented Jun 16, 2021

I wonder if this is somehow related to how the extension would fail when the OmniSharp race condition was present. The race prevented its didChangeConfiguration from reaching the server, causing it to never start. Manually triggering a second didChangeConfiguration would "fix" it. 🤔

That sounds very similar to what I was experiencing initially. Except the language client wasn't ever sending didChangeConfiguration.

I dug through the code trying to figure out what sets these values and determined that they were only getting set when the client sends didChangeConfiguration.

image

I stumbled across TypeFox/monaco-languageclient#201 and subsequently a conversation with the guys at Theia here where they say that the Language Server Protocol doesn't specify that the client needs to send didChangeConfiguration, but VS Code does it anyway. Which makes sense as to why this isn't a problem in you guys' testing.

The "new" way to do this is evidently to advertise support for didChangeConfiguration and have PSES ask for the configuration.

image

But truthfully it doesn't matter, as long as I am able to mimic VS Code's behavior of sending it, and not having PSES crash when the settings is null.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Jun 16, 2021
@andyleejordan
Copy link
Member

Woah, super informative. Thanks @dkattan! Also raxod052 is someone I used to work with a bit when I was using Emacs for everything (which was my entire life before I took over the VSCode extension for PowerShell). I think part of the backlog for PSES to actually update the logic to the new, modern spec with dynamic registrations and such, we just haven't gotten to it yet.

@andyleejordan andyleejordan removed the Needs: Maintainer Attention Maintainer attention needed! label Jun 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants