Skip to content

Commit 632a949

Browse files
DanTupcommit-bot@chromium.org
authored andcommitted
Log when LSP drops invalid notifications to the instrumentation log
Change-Id: I8388bf7fe42134fd20d9c7b9727a1f47e4d5a277 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/107285 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Danny Tuppeny <[email protected]>
1 parent bd9be3c commit 632a949

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

pkg/analysis_server/lib/src/lsp/handlers/handler_states.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ class InitializingStateMessageHandler extends ServerStateMessageHandler {
122122
ErrorOr<void> handleUnknownMessage(IncomingMessage message) {
123123
// Silently drop non-requests.
124124
if (message is! RequestMessage) {
125+
server.instrumentationService
126+
.logInfo('Ignoring ${message.method} message while initializing');
125127
return success();
126128
}
127129
return error(
@@ -142,6 +144,8 @@ class UninitializedStateMessageHandler extends ServerStateMessageHandler {
142144
FutureOr<ErrorOr<Object>> handleUnknownMessage(IncomingMessage message) {
143145
// Silently drop non-requests.
144146
if (message is! RequestMessage) {
147+
server.instrumentationService
148+
.logInfo('Ignoring ${message.method} message while uninitialized');
145149
return success();
146150
}
147151
return error(ErrorCodes.ServerNotInitialized,
@@ -159,6 +163,8 @@ class ShuttingDownStateMessageHandler extends ServerStateMessageHandler {
159163
FutureOr<ErrorOr<Object>> handleUnknownMessage(IncomingMessage message) {
160164
// Silently drop non-requests.
161165
if (message is! RequestMessage) {
166+
server.instrumentationService
167+
.logInfo('Ignoring ${message.method} message while shutting down');
162168
return success();
163169
}
164170
return error(ErrorCodes.InvalidRequest,

pkg/analyzer/lib/instrumentation/instrumentation.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class InstrumentationService {
7070
static const String TAG_ERROR = 'Err';
7171
static const String TAG_EXCEPTION = 'Ex';
7272
static const String TAG_FILE_READ = 'Read';
73+
static const String TAG_INFO = 'Info';
7374
static const String TAG_LOG_ENTRY = 'Log';
7475
static const String TAG_NOTIFICATION = 'Noti';
7576
static const String TAG_PERFORMANCE = 'Perf';
@@ -163,6 +164,11 @@ class InstrumentationService {
163164
}
164165
}
165166

167+
/**
168+
* Log unstructured text information for debugging purposes.
169+
*/
170+
void logInfo(String message) => _log(TAG_INFO, message);
171+
166172
/**
167173
* Log that a log entry that was written to the analysis engine's log. The log
168174
* entry has the given [level] and [message], and was created at the given

0 commit comments

Comments
 (0)