Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitfcdcd80

Browse files
authored
Fixing queuing logic that stalls LS on Mac (microsoft#2540)
1 parent126cf7c commitfcdcd80

File tree

3 files changed

+60
-22
lines changed

3 files changed

+60
-22
lines changed

‎Extension/src/LanguageServer/client.ts‎

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ export interface Client {
171171
updateCustomConfigurations(requestingProvider?:CustomConfigurationProvider1):Thenable<void>;
172172
updateCustomBrowseConfiguration(requestingProvider?:CustomConfigurationProvider1):Thenable<void>;
173173
provideCustomConfiguration(document:vscode.TextDocument):Promise<void>;
174-
getCustomConfigurationProviderId():Thenable<string|undefined>;
175174
getCurrentConfigName():Thenable<string>;
176175
takeOwnership(document:vscode.TextDocument):void;
177176
queueTask<T>(task:()=>Thenable<T>):Thenable<T>;
@@ -523,6 +522,7 @@ class DefaultClient implements Client {
523522

524523
publicupdateCustomBrowseConfiguration(requestingProvider?:CustomConfigurationProvider1):Thenable<void>{
525524
returnthis.notifyWhenReady(()=>{
525+
console.log("updateCustomBrowseConfiguration");
526526
if(!this.configurationProvider){
527527
return;
528528
}
@@ -536,6 +536,9 @@ class DefaultClient implements Client {
536536
if(awaitcurrentProvider.canProvideBrowseConfiguration(tokenSource.token)){
537537
returncurrentProvider.provideBrowseConfiguration(tokenSource.token);
538538
}
539+
if(currentProvider.version>=Version.v2){
540+
console.warn("failed to provide browse configuration");
541+
}
539542
returnPromise.reject("");
540543
};
541544
this.queueTaskWithTimeout(task,configProviderTimeout,tokenSource).then(
@@ -550,7 +553,7 @@ class DefaultClient implements Client {
550553
publicasyncprovideCustomConfiguration(document:vscode.TextDocument):Promise<void>{
551554
lettokenSource:CancellationTokenSource=newCancellationTokenSource();
552555
letproviders:CustomConfigurationProviderCollection=getCustomConfigProviders();
553-
556+
console.log("provideCustomConfiguration");
554557
if(providers.size===0){
555558
returnPromise.resolve();
556559
}
@@ -578,6 +581,7 @@ class DefaultClient implements Client {
578581
}
579582
}catch(err){
580583
}
584+
console.warn("failed to provide configuration");
581585
returnPromise.reject("");
582586
};
583587

@@ -617,7 +621,7 @@ class DefaultClient implements Client {
617621
returnutil.isHeader(document)&&!document.uri.toString().startsWith(this.RootUri.toString());
618622
}
619623

620-
publicgetCustomConfigurationProviderId():Thenable<string|undefined>{
624+
privategetCustomConfigurationProviderId():Thenable<string|undefined>{
621625
returnthis.queueTask(()=>Promise.resolve(this.configuration.CurrentConfigurationProvider));
622626
}
623627

@@ -651,22 +655,27 @@ class DefaultClient implements Client {
651655

652656
publicqueueTask(task:()=>Thenable<any>):Thenable<any>{
653657
if(this.isSupported){
654-
this.pendingRequests++;
655-
letnextTask:()=>Thenable<any>=()=>{
656-
letresult:Thenable<any>=task();
657-
this.pendingRequests--;
658-
if(this.pendingRequests===0){
659-
this.pendingTask=null;
658+
letnextTask:()=>Thenable<any>=async()=>{
659+
try{
660+
letresult:any=awaittask();
661+
this.pendingRequests--;
662+
returnresult;
663+
}catch(err){
664+
console.error(err);
665+
this.pendingRequests--;
666+
throwerr;
660667
}
661-
returnresult;
662668
};
663-
664-
if(this.pendingTask){
665-
// We don't want the queue to stall because of a rejected promise.
666-
returnthis.pendingTask.then(nextTask,nextTask);
667-
}else{
669+
670+
console.assert(this.pendingRequests>=0);
671+
if(this.pendingRequests===0){
672+
this.pendingRequests++;
668673
this.pendingTask=nextTask();
669674
returnthis.pendingTask;
675+
}else{
676+
// We don't want the queue to stall because of a rejected promise.
677+
this.pendingRequests++;
678+
returnthis.pendingTask.then(nextTask,nextTask);
670679
}
671680
}else{
672681
returnPromise.reject("Unsupported client");
@@ -1111,15 +1120,29 @@ class DefaultClient implements Client {
11111120
publicsendCustomConfigurations(configs:any):void{
11121121
// configs is marked as 'any' because it is untrusted data coming from a 3rd-party. We need to sanitize it before sending it to the language server.
11131122
if(!configs||!(configsinstanceofArray)){
1123+
console.warn("discarding invalid SourceFileConfigurationItems[]: "+configs);
11141124
return;
11151125
}
1126+
1127+
letsettings:CppSettings=newCppSettings(this.RootUri);
1128+
letout:logger.Logger=logger.getOutputChannelLogger();
1129+
if(settings.loggingLevel==="Debug"){
1130+
out.appendLine("Custom configurations received:");
1131+
}
11161132
letsanitized:SourceFileConfigurationItemAdapter[]=[];
11171133
configs.forEach(item=>{
11181134
if(this.isSourceFileConfigurationItem(item)){
11191135
sanitized.push({
11201136
uri:item.uri.toString(),
11211137
configuration:item.configuration
11221138
});
1139+
if(settings.loggingLevel==="Debug"){
1140+
out.appendLine(` uri:${item.uri.toString()}`);
1141+
out.appendLine(` config:${JSON.stringify(item.configuration,null,2)}`);
1142+
}
1143+
if(item.configuration.includePath.some(path=>path.endsWith('**'))){
1144+
console.warn("custom include paths should not use recursive includes ('**')");
1145+
}
11231146
}else{
11241147
console.warn("discarding invalid SourceFileConfigurationItem: "+item);
11251148
}
@@ -1138,6 +1161,7 @@ class DefaultClient implements Client {
11381161
publicsendCustomBrowseConfiguration(config:any):Thenable<void>{
11391162
// config is marked as 'any' because it is untrusted data coming from a 3rd-party. We need to sanitize it before sending it to the language server.
11401163
if(!config||configinstanceofArray){
1164+
console.warn("discarding invalid WorkspaceBrowseConfiguration: "+config);
11411165
returnPromise.resolve();
11421166
}
11431167
letsanitized:WorkspaceBrowseConfiguration=<WorkspaceBrowseConfiguration>config;
@@ -1147,6 +1171,12 @@ class DefaultClient implements Client {
11471171
returnPromise.resolve();
11481172
}
11491173

1174+
letsettings:CppSettings=newCppSettings(this.RootUri);
1175+
letout:logger.Logger=logger.getOutputChannelLogger();
1176+
if(settings.loggingLevel==="Debug"){
1177+
out.appendLine(`Custom browse configuration received:${JSON.stringify(sanitized,null,2)}`);
1178+
}
1179+
11501180
letparams:CustomBrowseConfigurationParams={
11511181
browseConfiguration:sanitized
11521182
};
@@ -1274,7 +1304,6 @@ class NullClient implements Client {
12741304
updateCustomConfigurations(requestingProvider?:CustomConfigurationProvider1):Thenable<void>{returnPromise.resolve();}
12751305
updateCustomBrowseConfiguration(requestingProvider?:CustomConfigurationProvider1):Thenable<void>{returnPromise.resolve();}
12761306
provideCustomConfiguration(document:vscode.TextDocument):Promise<void>{returnPromise.resolve();}
1277-
getCustomConfigurationProviderId():Thenable<string|undefined>{returnPromise.resolve(undefined);}
12781307
getCurrentConfigName():Thenable<string>{returnPromise.resolve("");}
12791308
takeOwnership(document:vscode.TextDocument):void{}
12801309
queueTask<T>(task:()=>Thenable<T>):Thenable<T>{returntask();}

‎Extension/src/LanguageServer/extension.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,10 @@ async function checkAndApplyUpdate(updateChannel: string): Promise<void> {
325325
reject(error);
326326
});
327327
});
328-
returnp.catch((error:Error)=>{
328+
awaitp.catch((error:Error)=>{
329329
// Handle .then following getTargetBuildInfo rejection
330330
logFailure(error);
331-
returnPromise.reject(error);
331+
throwerror;
332332
});
333333
}
334334

‎Extension/src/cppTools.ts‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import * as test from './testHook';
1414
exportclassCppToolsimplementsCppToolsTestApi{
1515
privateversion:Version;
1616
privateproviders:CustomConfigurationProvider1[]=[];
17+
privatefailedRegistrations:CustomConfigurationProvider[]=[];
1718
privatetimers=newMap<string,NodeJS.Timer>();
1819

1920
constructor(version:Version){
@@ -57,6 +58,8 @@ export class CppTools implements CppToolsTestApi {
5758
this.providers.push(added);
5859
LanguageServer.getClients().forEach(client=>client.onRegisterCustomConfigurationProvider(added));
5960
this.addNotifyReadyTimer(added);
61+
}else{
62+
this.failedRegistrations.push(provider);
6063
}
6164
}
6265

@@ -71,8 +74,10 @@ export class CppTools implements CppToolsTestApi {
7174
client.updateCustomConfigurations(p);
7275
client.updateCustomBrowseConfiguration(p);
7376
});
77+
}elseif(this.failedRegistrations.find(p=>p===provider)){
78+
console.warn("provider not successfully registered, 'notifyReady' ignored");
7479
}else{
75-
console.assert(false,"provider should be registered before signaling it's ready to provide configurations");
80+
console.warn(false,"provider should be registered before signaling it's ready to provide configurations");
7681
}
7782
}
7883

@@ -81,10 +86,12 @@ export class CppTools implements CppToolsTestApi {
8186
letp:CustomConfigurationProvider1=providers.get(provider);
8287

8388
if(p){
84-
console.assert(p.isReady,"didChangeCustomConfiguration was invoked before notifyReady");
89+
console.warn(p.isReady,"didChangeCustomConfiguration was invoked before notifyReady");
8590
LanguageServer.getClients().forEach(client=>client.updateCustomConfigurations(p));
91+
}elseif(this.failedRegistrations.find(p=>p===provider)){
92+
console.warn("provider not successfully registered, 'didChangeCustomConfiguration' ignored");
8693
}else{
87-
console.assert(false,"provider should be registered before sending config change messages");
94+
console.warn(false,"provider should be registered before sending config change messages");
8895
}
8996
}
9097

@@ -94,8 +101,10 @@ export class CppTools implements CppToolsTestApi {
94101

95102
if(p){
96103
LanguageServer.getClients().forEach(client=>client.updateCustomBrowseConfiguration(p));
104+
}elseif(this.failedRegistrations.find(p=>p===provider)){
105+
console.warn("provider not successfully registered, 'didChangeCustomBrowseConfiguration' ignored");
97106
}else{
98-
console.assert(false,"provider should be registered before sending config change messages");
107+
console.warn(false,"provider should be registered before sending config change messages");
99108
}
100109
}
101110

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp