Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: queue timeout precision #10

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Sources/FalClient/FalClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public struct FalClient: Client {
onQueueUpdate: OnQueueUpdate?
) async throws -> Payload {
let requestId = try await queue.submit(app, path: path, input: input)
let start = Int(Date().timeIntervalSince1970 * 1000)
var elapsed = 0
let start = Int64(Date().timeIntervalSince1970 * 1000)
var elapsed: Int64 = 0
var isCompleted = false
while elapsed < timeout.milliseconds {
let update = try await queue.status(app, of: requestId, includeLogs: includeLogs)
Expand All @@ -67,7 +67,7 @@ public struct FalClient: Client {
break
}
try await Task.sleep(nanoseconds: UInt64(Int(pollInterval.milliseconds * 1_000_000)))
elapsed += Int(Date().timeIntervalSince1970 * 1000) - start
elapsed = Int64(Date().timeIntervalSince1970 * 1000) - start
}
if !isCompleted {
throw FalError.queueTimeout
Expand Down
Loading