Skip to content

Commit 31c288e

Browse files
committed
Abort on too many retries
1 parent a2e1170 commit 31c288e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Tests/AppTests/Helpers/DatabasePool.swift

+7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ actor DatabasePool {
2929
}
3030
}
3131

32+
struct Error: Swift.Error {
33+
var message: String
34+
}
35+
3236
static let shared = DatabasePool(maxCount: Environment.databasePoolSize)
3337

3438
var maxCount: Int
@@ -157,6 +161,9 @@ actor DatabasePool {
157161
if retry > 0 && retry % 50 == 0 {
158162
print("ℹ️ \(#function) available databases: \(availableDatabases.count) retry \(retry)")
159163
}
164+
if retry >= 1000 {
165+
throw Error(message: "Retry count exceeded")
166+
}
160167
try await Task.sleep(for: .milliseconds(100))
161168
database = availableDatabases.randomElement()
162169
}

0 commit comments

Comments
 (0)