From 19aa91eff2a221770b83cd61c7c1a239bb639503 Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Tue, 21 Dec 2021 14:53:47 +0100 Subject: [PATCH] Fix crash when closing socket --- Sources/App/Model/Players/Player.swift | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Sources/App/Model/Players/Player.swift b/Sources/App/Model/Players/Player.swift index 90404d0..8cc4762 100644 --- a/Sources/App/Model/Players/Player.swift +++ b/Sources/App/Model/Players/Player.swift @@ -71,10 +71,8 @@ extension Player { guard let socket = socket else { return false } - do { - try socket.close().wait() - } catch { - print("Failed to close socket for player: \(name): \(error)") + socket.close().whenFailure { [weak self] error in + print("Failed to close socket for player: \(self?.name ?? ""): \(error)") } self.socket = nil return true