Skip to content

Commit 9350b85

Browse files
DanTupCommit Queue
authored andcommitted
[analysis_server] Add a missing 'await' that may prevent handling of InconsistentAnalysisException
This test (without the code fix) reproduces an infinite loop in the GetFixes handler. There is error handling for `InconsistentAnalysisException` but it didn't appear to work (at least in some cases) because it's async and there was no `await`. Change-Id: I835398062ea3da1386c2bc065bbdaf93cf10cdf1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396820 Reviewed-by: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent d37c754 commit 9350b85

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

pkg/analysis_server/lib/src/analysis_server.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ abstract class AnalysisServer {
763763
return null;
764764
}
765765
try {
766-
return driver.currentSession.getResolvedContainingLibrary(path);
766+
return await driver.currentSession.getResolvedContainingLibrary(path);
767767
} on InconsistentAnalysisException {
768768
return null;
769769
} catch (exception, stackTrace) {

pkg/analysis_server/test/edit/fixes_test.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
import 'dart:async';
6+
57
import 'package:analysis_server/protocol/protocol_generated.dart';
68
import 'package:analysis_server/src/analysis_server.dart';
79
import 'package:analysis_server/src/plugin/plugin_manager.dart';
@@ -33,6 +35,29 @@ class FixesTest extends PubPackageAnalysisServerTest {
3335
await setRoots(included: [workspaceRootPath], excluded: []);
3436
}
3537

38+
Future<void> test_concurrentModifications() async {
39+
var file = server.resourceProvider.getFile(testFile.path);
40+
var futures = <Future<void>>[];
41+
42+
// Send many requests to modify files and get fixes.
43+
for (var i = 1; i < 100; i++) {
44+
futures.add(_addOverlay(testFile.path, 'var i = $i;'));
45+
await pumpEventQueue();
46+
futures.add(
47+
handleSuccessfulRequest(
48+
EditGetFixesParams(
49+
file.path,
50+
0,
51+
).toRequest('$i', clientUriConverter: server.uriConverter),
52+
),
53+
);
54+
await pumpEventQueue();
55+
}
56+
57+
// Except all to complete.
58+
await Future.wait(futures);
59+
}
60+
3661
Future<void> test_fileOutsideRoot() async {
3762
var outsideFile = '/foo/test.dart';
3863
newFile(outsideFile, 'bad code to create error');

0 commit comments

Comments
 (0)