Skip to content

Commit

Permalink
Add a timeout
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
helje5 authored Dec 12, 2024
1 parent bfb4fa4 commit 2518df9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/WebPush/WebPushManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2518df9

Please sign in to comment.