Skip to content

Commit f81410f

Browse files
committed
deflake test
1 parent 94fce5f commit f81410f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Tests/GRPCInProcessTransportTests/ClientServerWithMethods.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,20 @@ fileprivate actor TestActor {
3636
let inProcess = InProcessTransport()
3737

3838
try await withGRPCServer(transport: inProcess.server, services: []) { server in
39-
try await withGRPCClient(transport: inProcess.client) { client in
40-
self.hasRun = true
39+
do {
40+
try await withGRPCClient(transport: inProcess.client) { client in
41+
self.hasRun = true
42+
}
43+
} catch {
44+
// Starting the client can race with the closure returning which begins graceful shutdown.
45+
// If that happens the client run method will throw an error as the client is being run
46+
// when it's already been shutdown. That's okay and expected so rather than slowing down
47+
// the closure tolerate that specific error.
48+
if let error = error as? RuntimeError {
49+
#expect(error.code == .clientIsStopped)
50+
} else {
51+
Issue.record(error)
52+
}
4153
}
4254
}
4355
}

0 commit comments

Comments
 (0)