Open
Description
Describe the issue
When using PostgresClient, making requests to a IP:port that isn't serving a postgres database will never throw an error and retry forever
Vapor version
Not using vapor, but PostgresKit is v2.13.5
Operating system and version
macOS 15.0 beta 1
Swift version
Swift 6 (from Xcode 16 beta 1)
Steps to reproduce
- Create an empty Swift package
- Add PostgresKit as a dependency to the package and the executableTarget
- Write the following code in the
main.swift
file
import PostgresKit
let config = PostgresClient.Configuration(
host: "localhost",
port: 5432,
username: "my_username",
password: "my_password",
database: "my_database",
tls: .disable
)
let client = PostgresClient(configuration: config)
try await withThrowingTaskGroup(of: Void.self) { taskGroup in
taskGroup.addTask {
await client.run() // !important
}
try await client.withConnection { connection in
let db = connection.sql()
let row = try await db.raw("SELECT 1 as healthy").first()
print(try row?.decode(column: "healthy", as: Int.self))
}
}
- Run the project, make sure there is no Postgres server running and replying to
localhost:5432
Outcome
The db.raw
call never returns, and the following log can be seen repeatedly in the console:
nw_endpoint_flow_failed_with_error [C37.1.2 127.0.0.1:5432 in_progress socket-flow (satisfied (Path is satisfied), viable, interface: lo0)] already failing, returning
nw_endpoint_flow_failed_with_error [C37.1.2 127.0.0.1:5432 cancelled socket-flow ((null))] already failing, returning
The expected behaviour would be that after a given configurable number of retries, the method would throw an error. As of now, there seem to be no way to detect a failing connection to the database.
Additional notes
My computer is an M1 Ultra. I run the latest macOS and Xcode beta and sadly I can't test with a stable version of macOS.