From 2518df9b4a5edee605436ab4dfc4f8d38fc6c17b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helge=20He=C3=9F?= Date: Thu, 12 Dec 2024 18:38:50 +0100 Subject: [PATCH] Add a timeout Without the timeout the request expires immediately and results in the `HTTPClientError.deadlineExceeded`. I'm not sure why the async methods of AsyncHTTPClient don't allow a `nil` deadline like other methods (to use the overall client default). This patch makes it work, but maybe there should be a more general way to configure the timeout. --- Sources/WebPush/WebPushManager.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/WebPush/WebPushManager.swift b/Sources/WebPush/WebPushManager.swift index 8ee4142..8e8969b 100644 --- a/Sources/WebPush/WebPushManager.swift +++ b/Sources/WebPush/WebPushManager.swift @@ -371,7 +371,7 @@ public actor WebPushManager: Sendable { request.body = .bytes(ByteBuffer(bytes: requestContent)) /// Send the request to the push endpoint. - let response = try await httpClient.execute(request, deadline: .now(), logger: logger) + let response = try await httpClient.execute(request, deadline: .now() + .seconds(2), logger: logger) /// Check the response and determine if the subscription should be removed from our records, or if the notification should just be skipped. switch response.status {