Skip to content

Commit ce0fded

Browse files
committed
Fix flaky test
1 parent 25ce8b2 commit ce0fded

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Tests/NIOHTTPServerTests/NIOHTTPServer+ServiceLifecycleTests.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ struct NIOHTTPServiceLifecycleTests {
184184
// Wait for the server to shut down.
185185
try await group.waitForAll()
186186

187+
// Wait for the client channel to be fully closed. The server has closed
188+
// its side of the connection, but the client's event loop may not have
189+
// processed the TCP FIN/RST yet. closeFuture completes only once the
190+
// channel is fully inactive, which is a stronger guarantee than just
191+
// draining inbound (which may return while the channel is half-closed).
192+
try await client.channel.closeFuture.get()
193+
187194
// We shouldn't be able to complete our request; the server should have shut down.
188195
await #expect(throws: ChannelError.ioOnClosedChannel) {
189196
try await outbound.write(Self.reqBody)

0 commit comments

Comments
 (0)