feat(boot): add server boot integration tests and fix ValueTask sync blocking
Fix Shutdown()/LameDuckMode() deadlock caused by calling .GetAwaiter().GetResult() on pending ValueTask from Channel.ReadAsync(). ValueTask does not support synchronous blocking — must convert via .AsTask() first. Add two integration tests validating the full Start() → AcceptLoop → client connection → Shutdown lifecycle.
This commit is contained in:
@@ -127,8 +127,9 @@ public sealed partial class NatsServer
|
||||
}
|
||||
|
||||
// Wait for accept loops to exit.
|
||||
// Must use .AsTask() because ValueTask cannot be synchronously blocked on.
|
||||
for (int i = 0; i < doneExpected; i++)
|
||||
_done.Reader.ReadAsync().GetAwaiter().GetResult();
|
||||
_done.Reader.ReadAsync().AsTask().GetAwaiter().GetResult();
|
||||
|
||||
// Wait for all goroutines.
|
||||
_grWg.Wait();
|
||||
@@ -655,8 +656,9 @@ public sealed partial class NatsServer
|
||||
ShutdownRaftNodes();
|
||||
|
||||
// Wait for accept loops.
|
||||
// Must use .AsTask() because ValueTask cannot be synchronously blocked on.
|
||||
for (int i = 0; i < expected; i++)
|
||||
_ldmCh.Reader.ReadAsync().GetAwaiter().GetResult();
|
||||
_ldmCh.Reader.ReadAsync().AsTask().GetAwaiter().GetResult();
|
||||
|
||||
_mu.EnterWriteLock();
|
||||
var clients = new List<ClientConnection>(_clients.Values);
|
||||
|
||||
Reference in New Issue
Block a user