Skip to content

Commit ad0d6db

Browse files
authored
Check if poll timed out (#150)
1 parent 45551e8 commit ad0d6db

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

client/helpers/queued-jobs.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export async function pollQueuedJob<T>({
149149
}
150150

151151
export function isPollError<T>(r: PollRes<T>): r is QueuedJob | Failure {
152-
return isQueuedJobError(r) || isFailure(r);
152+
return isQueuedJobError(r) || isQueuedJobRunning(r) || isFailure(r);
153153
}
154154

155155
export function isBatch(obj: PollRes<Batch>): obj is Batch {
@@ -188,6 +188,11 @@ function isQueuedJobError(obj: any): obj is QueuedJob {
188188
return isQueuedJob(obj) && isStatusError(obj);
189189
}
190190

191+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
192+
function isQueuedJobRunning(obj: any): obj is QueuedJob {
193+
return isQueuedJob(obj) && isStatusRunning(obj);
194+
}
195+
191196
function isStatusComplete(job: QueuedJob): boolean {
192197
return job.data.attributes.status === 'complete';
193198
}
@@ -196,6 +201,10 @@ function isStatusError(job: QueuedJob): boolean {
196201
return job.data.attributes.status === 'error';
197202
}
198203

204+
function isStatusRunning(job: QueuedJob): boolean {
205+
return job.data.attributes.status === 'running';
206+
}
207+
199208
function isClientError<T>(res: PollRes<T>): boolean {
200209
return isFailure(res) && head([...res.errors.values()])?.id === ClientErrorId;
201210
}

0 commit comments

Comments
 (0)