Remove analysis server shutdown timeout

See https://fxbug.dev/98703; this shutdown is sometimes taking longer
than the arbitrary 1 second timeout used here. Make the timeout argument
optional and avoid setting it in the analyze command.

This timeout was previously raised in response to issues in fuchsia in
https://dart-review.googlesource.com/c/sdk/+/237780.

Change-Id: Ic896c36a37735bb49d13cde07a95a6fe7837b580
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269061
Reviewed-by: Jacob Richman <jacobr@google.com>
Commit-Queue: Jacob Richman <jacobr@google.com>
Auto-Submit: Tamir Duberstein <tamird@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Tamir Duberstein 2022-11-11 00:30:10 +00:00 committed by Commit Queue
parent 207a47145f
commit 154843a376
2 changed files with 11 additions and 11 deletions

View file

@ -205,17 +205,15 @@ class AnalysisServer {
});
}
Future<void> shutdown({Duration timeout = const Duration(seconds: 5)}) async {
Future<void> shutdown({Duration? timeout}) async {
// Request shutdown.
await _sendCommand('server.shutdown').then((value) {
final Future<void> future = _sendCommand('server.shutdown').then((Map<String, dynamic> value) {
_shutdownResponseReceived = true;
return null;
}).timeout(timeout, onTimeout: () async {
log.stderr('The analysis server timed out while shutting down.');
await dispose();
}).then((value) async {
await dispose();
return;
});
await (timeout != null ? future.timeout(timeout, onTimeout: () {
log.stderr('The analysis server timed out while shutting down.');
}) : future).whenComplete(dispose);
}
/// Send an `analysis.updateContent` request with the given [files].
@ -233,12 +231,14 @@ class AnalysisServer {
'params': params,
});
_requestCompleters[id] = Completer();
final Completer<Map<String, dynamic>> completer = Completer();
_requestCompleters[id] = completer;
_process!.stdin.writeln(message);
log.trace('==> $message');
return _requestCompleters[id]!.future;
return completer.future;
}
void _handleServerResponse(String line) {

View file

@ -190,7 +190,7 @@ class AnalyzeCommand extends DartdevCommand {
await server.analysisFinished;
analysisFinished = true;
await server.shutdown(timeout: Duration(seconds: 1));
await server.shutdown();
progress?.finish(showTiming: true);