@@ -122,6 +122,7 @@ class CustomLintServer {
122122 BehaviorSubject <SocketCustomLintServerToClientChannel ?>();
123123 final _contextRoots = BehaviorSubject <AnalysisSetContextRootsParams >();
124124 final _runner = PendingOperation ();
125+ final _delayedRequest = < Request > [];
125126
126127 /// A shorthand for accessing the current list of context roots.
127128 Future <List <ContextRoot >?> get _allContextRoots {
@@ -186,7 +187,10 @@ class CustomLintServer {
186187 orElse: () async {
187188 return _runner.run (() async {
188189 final clientChannel = await _clientChannel.safeFirst;
189- if (clientChannel == null ) return null ;
190+ if (clientChannel == null || ! clientChannel.initialed) {
191+ _delayedRequest.add (request);
192+ return null ;
193+ }
190194
191195 final response =
192196 await clientChannel.sendAnalyzerPluginRequest (request);
@@ -291,6 +295,7 @@ class CustomLintServer {
291295 return _closeFuture = Future (() async {
292296 // Cancel pending operations
293297 await _contextRoots.close ();
298+ _delayedRequest.clear ();
294299
295300 // Flushes logs before stopping server.
296301 await _runner.wait ();
@@ -396,6 +401,14 @@ class CustomLintServer {
396401 await clientChannel.init (
397402 debug: configs.any ((e) => e != null && e.debug),
398403 );
404+ _sendDelayedRequest ();
405+ }
406+
407+ void _sendDelayedRequest () {
408+ for (final request in _delayedRequest) {
409+ unawaited (_handleRequest (request));
410+ }
411+ _delayedRequest.clear ();
399412 }
400413
401414 Future <void > _handleEvent (CustomLintEvent event) => _runner.run (() async {
0 commit comments