@@ -122,6 +122,7 @@ class CustomLintServer {
122
122
BehaviorSubject <SocketCustomLintServerToClientChannel ?>();
123
123
final _contextRoots = BehaviorSubject <AnalysisSetContextRootsParams >();
124
124
final _runner = PendingOperation ();
125
+ final _delayedRequest = < Request > [];
125
126
126
127
/// A shorthand for accessing the current list of context roots.
127
128
Future <List <ContextRoot >?> get _allContextRoots {
@@ -186,7 +187,10 @@ class CustomLintServer {
186
187
orElse: () async {
187
188
return _runner.run (() async {
188
189
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
+ }
190
194
191
195
final response =
192
196
await clientChannel.sendAnalyzerPluginRequest (request);
@@ -291,6 +295,7 @@ class CustomLintServer {
291
295
return _closeFuture = Future (() async {
292
296
// Cancel pending operations
293
297
await _contextRoots.close ();
298
+ _delayedRequest.clear ();
294
299
295
300
// Flushes logs before stopping server.
296
301
await _runner.wait ();
@@ -396,6 +401,14 @@ class CustomLintServer {
396
401
await clientChannel.init (
397
402
debug: configs.any ((e) => e != null && e.debug),
398
403
);
404
+ _sendDelayedRequest ();
405
+ }
406
+
407
+ void _sendDelayedRequest () {
408
+ for (final request in _delayedRequest) {
409
+ unawaited (_handleRequest (request));
410
+ }
411
+ _delayedRequest.clear ();
399
412
}
400
413
401
414
Future <void > _handleEvent (CustomLintEvent event) => _runner.run (() async {
0 commit comments