From d9bd0c6e303a21f4d2b2e221eec234e2ecff1337 Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Fri, 8 Dec 2023 16:55:47 +0100 Subject: [PATCH] Fix race condition waiting for message delivery --- Sources/App/DeviceManager.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/App/DeviceManager.swift b/Sources/App/DeviceManager.swift index 98723a9..ea8095b 100644 --- a/Sources/App/DeviceManager.swift +++ b/Sources/App/DeviceManager.swift @@ -79,7 +79,6 @@ final class DeviceManager { } do { try await socket.send(Array(message)) - await updateMessageCountMetric() } catch { throw MessageResult.deviceNotConnected } @@ -88,6 +87,7 @@ final class DeviceManager { let result: Data = try await withCheckedThrowingContinuation { continuation in self.requestInProgress = continuation } + await updateMessageCountMetric() return result } @@ -163,6 +163,7 @@ final class DeviceManager { self?.didCloseDeviceSocket() } } + log("[INFO] Socket connected") await updateDeviceConnectionMetric() } }