File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -686,17 +686,29 @@ extension ServerBootstrap {
686686
687687 try await withTaskCancellationHandler {
688688 try await channel. executeThenClose { inbound, outbound in
689- try await withThrowingDiscardingTaskGroup { group in
690- try await channel. executeThenClose { inbound in
691- for try await connectionChannel in inbound {
692- group. addTask {
693- try await connectionChannel. executeThenClose { _, _ in
694- try await onConnection ( connectionChannel)
689+ // we need to dance the result dance here, since we can't throw from the
690+ // withDiscardingTaskGroup closure.
691+ let result = await withDiscardingTaskGroup { group -> Result < Void , any Error > in
692+ do {
693+ try await channel. executeThenClose { inbound in
694+ for try await connectionChannel in inbound {
695+ group. addTask {
696+ do {
697+ try await connectionChannel. executeThenClose { _, _ in
698+ try await onConnection ( connectionChannel)
699+ }
700+ } catch {
701+ // ignore single connection failures?
702+ }
695703 }
696704 }
697705 }
706+ return . success( ( ) )
707+ } catch {
708+ return . failure( error)
698709 }
699710 }
711+ try result. get ( )
700712 }
701713 } onCancel: {
702714 channel. channel. close ( promise: nil )
You can’t perform that action at this time.
0 commit comments