Fix race condition waiting for message delivery

This commit is contained in:
Christoph Hagen 2023-12-08 16:55:47 +01:00
parent 9feab409ab
commit d9bd0c6e30

View File

@ -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()
}
}