From 190599de78dea095ad9e5c17aba1dd3b11f6be62 Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Fri, 31 May 2019 14:45:24 +0000 Subject: [PATCH] Skip LSP cancellation handling for Notification requests Change-Id: I0edf6206db66ed07390dafcd5ea72bb2397468fc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104300 Reviewed-by: Brian Wilkerson Commit-Queue: Danny Tuppeny --- .../lib/src/lsp/handlers/handlers.dart | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handlers.dart b/pkg/analysis_server/lib/src/lsp/handlers/handlers.dart index 77a21a6640b..89a8c1b7f59 100644 --- a/pkg/analysis_server/lib/src/lsp/handlers/handlers.dart +++ b/pkg/analysis_server/lib/src/lsp/handlers/handlers.dart @@ -121,16 +121,14 @@ abstract class ServerStateMessageHandler { return handleUnknownMessage(message); } + if (message is! RequestMessage) { + return handler.handleMessage(message, _notCancelableToken); + } + // Create a cancellation token that will allow us to cancel this request if // requested to save processing (the handler will need to specifically // check the token after `await` points). - // - // Notifications cannot be cancelled so they get a fake token that will never - // cancel so that they can share the same APIs with cancellable requests. - final token = message is RequestMessage - ? _cancelHandler.createToken(message) - : _notCancelableToken; - + final token = _cancelHandler.createToken(message); try { final result = await handler.handleMessage(message, token); // Do a final check before returning the result, because if the request was @@ -141,9 +139,7 @@ abstract class ServerStateMessageHandler { await Future.delayed(Duration.zero); return token.isCancellationRequested ? cancelled() : result; } finally { - if (message is RequestMessage) { - _cancelHandler.clearToken(message); - } + _cancelHandler.clearToken(message); } }