Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix issue with didOpen processed before initial custom browse config#4846

Merged
Colengms merged 9 commits into
mastermicrosoft/vscode-cpptools:masterfrom
coleng/fix_didOpen_before_custom_browsemicrosoft/vscode-cpptools:coleng/fix_didOpen_before_custom_browseCopy head branch name to clipboard
Jan 15, 2020
Merged

Fix issue with didOpen processed before initial custom browse config#4846
Colengms merged 9 commits into
mastermicrosoft/vscode-cpptools:masterfrom
coleng/fix_didOpen_before_custom_browsemicrosoft/vscode-cpptools:coleng/fix_didOpen_before_custom_browseCopy head branch name to clipboard

Conversation

@Colengms

Copy link
Copy Markdown
Contributor

Should address incomplete fix to #4802

Updates sendCustomBrowseConfiguration to avoid using notifyWhenReady(), in order to ensure the 'last seen' custom browse configuration is delivered on start up before any pending didOpen is processed. The other places this is called are already within a notifyWhenReady().

Fixes an extension ID check to consider vector-of-bool.cmake-tools and ms-vscode.cmake-tools to be equivalent.

Removed a no longer used arg and related code from notifyWhenReady.

});
this.doneInitialCustomBrowseConfigurationCheck = true;
}
this.languageClient.sendNotification(ChangeFolderSettingsNotification, params);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notifyWhenReady ensures that the languageClient is in a state that it can be used. What mechanism are you putting in place to ensure that you don't crash here?

@sean-mcmanus sean-mcmanus Jan 14, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't crashing when I tested it out...was my testing insufficient?

FYI, this fixes the 100% repro of the database clearing with a file open, but I was getting a 2nd harder to repro race condition case still.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code in question (sending the initial folder settings) needs to happen before the language client can be used (particularly didOpen needs to be delayed), so this needs to precede anything else that was queued using notifyWhenReady(). When this is called for the first time, it's triggered by the setting of CompilerDefaults, which occurs in a continuation after a prior call to languageClient.sendRequest() (roughly line 817). That would seem to imply it's OK to use languageClient to send messages at that point. All other calls that could wind up here appear to be protected by notifyWhenReady(), or are otherwise only possible if the client is ready. Please let me know if you can identify any cases in which we could wind up here when the client is not ready. Is the client ready at the point in realActivation() where we install callbacks?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code has changed a lot since I wrote it, so if you're confident there is no race here, then you can move forward with it. I'm just voicing concerns based on past problems we experienced with crashing while trying to send messages before the language client was ready. As a result, I tried to wrap everything with the *whenReady functions. If this is safe, please add a comment here stating why a *whenReady isn't needed. I used to do periodic checks for sendNotification calls outside of the *whenReady context.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have traced all existing calls back to either use of notifyWhenReady, or other evidence that it should be safe (such occurring near the end of the client constructor, where we have an existing call to languageClient.sendRequest. I added use of notifyWhenReady to onDidChangeSettings, as it might be needed there.

There is one remaining code path that I'm having trouble with. In configurations.ts, buildVcpkgIncludePath() is invoking this.handleConfigurationChange() in a finally block. buildVcpkgIncludePath() is called from the constructor of CppProperties. It's unclear to me if it's possible it might (as it's async) trigger a onConfigurationsChanged somewhere in the middle of the onReady() block in the client constructor. But, since all of that is non-async and makes use of languageClient.sendRequest(), it might actually be safe.

@bobbrow bobbrow dismissed their stale review January 15, 2020 21:12

non-issue

@Colengms Colengms merged commit 419d5c1 into master Jan 15, 2020
@Colengms Colengms deleted the coleng/fix_didOpen_before_custom_browse branch January 15, 2020 22:16
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.