From 5ff8acc6710136297ae436967b081278a10a4eae Mon Sep 17 00:00:00 2001 From: Stefan Jandl Date: Mon, 19 Aug 2024 18:51:01 +0200 Subject: [PATCH] fix: Prevent deadlock in `Hub.Dispose` (#3539) * no deadlock * Format code * sync * comment * . * Updated CHANGELOG.md --------- Co-authored-by: Sentry Github Bot --- CHANGELOG.md | 6 ++++++ src/Sentry/Internal/Hub.cs | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fb9c21d4b..84ff55a9db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +## Fixes + +- Resolved a potential deadlock during SDK shutdown ([#3539](https://github.com/getsentry/sentry-dotnet/pull/3539)) + ## 4.10.1 ### Fixes diff --git a/src/Sentry/Internal/Hub.cs b/src/Sentry/Internal/Hub.cs index 2a40489c33..151150514a 100644 --- a/src/Sentry/Internal/Hub.cs +++ b/src/Sentry/Internal/Hub.cs @@ -613,14 +613,14 @@ public void Dispose() try { Metrics.FlushAsync().ContinueWith(_ => - CurrentClient.FlushAsync(_options.ShutdownTimeout).Wait() + CurrentClient.FlushAsync(_options.ShutdownTimeout).ConfigureAwait(false).GetAwaiter().GetResult() ).ConfigureAwait(false).GetAwaiter().GetResult(); } catch (Exception e) { _options.LogError(e, "Failed to wait on disposing tasks to flush."); } - //Dont dispose of ScopeManager since we want dangling transactions to still be able to access tags. + //Don't dispose of ScopeManager since we want dangling transactions to still be able to access tags. #if __IOS__ // TODO