Skip to content

Commit d96c42e

Browse files
committed
fix: dont await dispoes async, can cause deadlocks
1 parent 5ca726d commit d96c42e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/bunit.core/TestContextBase.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,13 @@ protected virtual void Dispose(bool disposing)
9191
renderer.Dispose();
9292
}
9393

94+
// Ignore the async task as GetAwaiter().GetResult() can cause deadlock
95+
// and implementing IAsyncDisposable in TestContext will be a breaking change.
96+
//
9497
// NOTE: This has to be called before Services.Dispose().
9598
// If there are IAsyncDisposable services registered, calling Dispose first
9699
// causes the service provider to throw an exception.
97-
Services.DisposeAsync().GetAwaiter().GetResult();
100+
_ = Services.DisposeAsync();
98101

99102
// The service provider should dispose of any
100103
// disposable object it has created, when it is disposed.

0 commit comments

Comments
 (0)