Skip to content

Commit

Permalink
Merge pull request #73997 from dibarbet/flaky_lsp_disconnect_test
Browse files Browse the repository at this point in the history
Fix flaky test: LanguageServerCleansUpOnUnexpectedJsonRpcDisconnectAsync
  • Loading branch information
dibarbet committed Jun 17, 2024
2 parents a1d0ddd + b13ed1b commit 47298b8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,13 @@ public async Task AssertServerShuttingDownAsync()
{
var queueAccessor = GetQueueAccessor()!.Value;
await queueAccessor.WaitForProcessingToStopAsync().ConfigureAwait(false);
Assert.True(GetServerAccessor().HasShutdownStarted());
Assert.True(queueAccessor.IsComplete());

var shutdownTask = GetServerAccessor().GetShutdownTaskAsync();
AssertEx.NotNull(shutdownTask, "Unexpected shutdown not started");

// Shutdown task will close the queue, so we need to wait for it to complete.
await shutdownTask.ConfigureAwait(false);
Assert.True(queueAccessor.IsComplete(), "Unexpected queue not complete");
}

internal async Task WaitForDiagnosticsAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,15 @@ internal Task<TResponse> ExecuteRequestAsync<TRequest, TResponse>(string methodN
internal JsonRpc GetServerRpc() => _server._jsonRpc;

internal bool HasShutdownStarted()
{
return GetShutdownTaskAsync() != null;
}

internal Task? GetShutdownTaskAsync()
{
lock (_server._lifeCycleLock)
{
return _server._shutdownRequestTask != null;
return _server._shutdownRequestTask;
}
}
}
Expand Down

0 comments on commit 47298b8

Please sign in to comment.