From 4fc7cb1c9731dcffe633a30e2964cce64f0e4fcc Mon Sep 17 00:00:00 2001 From: Yannick Cholette Date: Tue, 13 Feb 2024 15:56:30 -0500 Subject: [PATCH] Use a timeout when calling RequestShutdown() --- src/Client/LanguageClient.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Client/LanguageClient.cs b/src/Client/LanguageClient.cs index 22c7004df..8c05daa8c 100644 --- a/src/Client/LanguageClient.cs +++ b/src/Client/LanguageClient.cs @@ -423,7 +423,16 @@ public async Task Shutdown() { if (_connection.IsOpen) { - await this.RequestShutdown().ConfigureAwait(false); + try + { + // this can get stuck forever, so use a timeout. + var cancelSource = new CancellationTokenSource(); + cancelSource.CancelAfter(5 * 1000); + + await this.RequestShutdown(cancelSource.Token).ConfigureAwait(false); + } + catch (TaskCanceledException) { } + this.SendExit(); }