Skip to content

Commit b6647fd

Browse files
scheglovCommit Queue
authored and
Commit Queue
committed
Stop listening AnalysisDriverScheduler stream during server shutdown.
So, that we don't send analyzing/idle during drivers dispose. Change-Id: I589cc368b2877baa0878d405f7ab3ca7daf31f3c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348763 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent c975fdf commit b6647fd

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

pkg/analysis_server/lib/src/analysis_server.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ abstract class AnalysisServer {
138138

139139
late analysis.AnalysisDriverScheduler analysisDriverScheduler;
140140

141+
late StreamSubscription<Object?>? analysisDriverSchedulerEventsSubscription;
142+
141143
DeclarationsTracker? declarationsTracker;
142144

143145
/// The DiagnosticServer for this AnalysisServer. If available, it can be used
@@ -849,6 +851,9 @@ abstract class AnalysisServer {
849851

850852
@mustCallSuper
851853
Future<void> shutdown() async {
854+
await analysisDriverSchedulerEventsSubscription?.cancel();
855+
analysisDriverSchedulerEventsSubscription = null;
856+
852857
// For now we record plugins only on shutdown. We might want to record them
853858
// every time the set of plugins changes, in which case we'll need to listen
854859
// to the `PluginManager.pluginsChanged` stream.

pkg/analysis_server/lib/src/legacy_analysis_server.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,8 @@ class LegacyAnalysisServer extends AnalysisServer {
406406
ServerContextManagerCallbacks(this, resourceProvider);
407407
contextManager.callbacks = contextManagerCallbacks;
408408

409-
analysisDriverScheduler.events.listen(handleAnalysisEvent);
409+
analysisDriverSchedulerEventsSubscription =
410+
analysisDriverScheduler.events.listen(handleAnalysisEvent);
410411
analysisDriverScheduler.start();
411412

412413
onAnalysisStarted.first.then((_) {

pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ class LspAnalysisServer extends AnalysisServer {
178178
LspServerContextManagerCallbacks(this, resourceProvider);
179179
contextManager.callbacks = contextManagerCallbacks;
180180

181-
analysisDriverScheduler.events.listen(handleAnalysisEvent);
181+
analysisDriverSchedulerEventsSubscription =
182+
analysisDriverScheduler.events.listen(handleAnalysisEvent);
182183
analysisDriverScheduler.start();
183184

184185
_channelSubscription =

0 commit comments

Comments
 (0)