Skip to content

Commit 580e90a

Browse files
committed
added await on func connect
1 parent b6e89f4 commit 580e90a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Sources/SQLClientSwift/SQLClient.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ public actor SQLClient {
141141
public func connect(options: SQLClientConnectionOptions) async throws {
142142
guard !connected else { throw SQLClientError.alreadyConnected }
143143

144+
try await checkReachability(server: options.server, port: options.port ?? 1433)
145+
144146
let result = try await runBlocking {
145147
return try self._connectSync(options: options)
146148
}
@@ -234,10 +236,6 @@ private func checkReachability(server: String, port: UInt16) async throws {
234236
}
235237

236238
private nonisolated func _connectSync(options: SQLClientConnectionOptions) throws -> (login: TDSHandle, connection: TDSHandle) {
237-
// Pre-flight — fail fast if the server isn't reachable at the TCP level.
238-
// Default port for SQL Server is 1433.
239-
try checkReachability(server: options.server, port: options.port ?? 1433)
240-
241239
dbinit()
242240
dberrhandle(SQLClient_errorHandler)
243241
dbmsghandle(SQLClient_messageHandler)

0 commit comments

Comments
 (0)