ITADN

Trying to connecting to non-existing database using `PostgresClient`, queries hang indefinitely with no error thrown

#602Closedahoppen 创建于 2025-11-17
A
ahoppencommented
When using `PostgresClient` and trying to connect to a database that doesn’t exist, no error is thrown. Instead, any attempt to run a query just hangs, no error is thrown. When connecting using `PostgresConnection`, an error is thrown at connection time. To reproduce, add the following test to IntegrationTests/PostgresNIOTests.swift and run it. Notice how it just hangs, I would have expected an error to be thrown from `query`. ```swift func testConnectToNonexistingDatabase() async throws { let config = PostgresClient.Configuration( host: env("POSTGRES_HOSTNAME") ?? "localhost", port: env("POSTGRES_PORT").flatMap(Int.init(_:)) ?? 5432, username: env("POSTGRES_USER") ?? "test_username", password: env("POSTGRES_PASSWORD") ?? "test_password", database: "does_not_exist", tls: .disable ) let client = PostgresClient(configuration: config) try await withThrowingTaskGroup { taskGroup in taskGroup.addTask { await client.run() } try await client.query("SELECT 1") } } ```
关闭于 2026-06-04 2 条评论