File size: 963 Bytes
d47b053
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import type { ProcessingStage } from '../../types'

export function shouldDisableQueueRetry(errorMessage: string): boolean {
  return errorMessage.includes('Code retry failed after') || errorMessage.includes('Static guard failed after')
}

export function getRetryMeta(job: any): {
  currentAttempt: number
  maxAttempts: number
  hasRemainingAttempts: boolean
} {
  const maxAttempts = typeof job?.opts?.attempts === 'number' && job.opts.attempts > 0 ? job.opts.attempts : 1
  const currentAttempt = (job?.attemptsMade ?? 0) + 1
  return {
    currentAttempt,
    maxAttempts,
    hasRemainingAttempts: currentAttempt < maxAttempts
  }
}

export async function storeProcessingStage(
  jobId: string,
  stage: ProcessingStage,
  options?: {
    status?: 'queued' | 'processing'
    attempt?: number
    submittedAt?: string
  }
): Promise<void> {
  const { storeJobStage } = await import('../../services/job-store')
  await storeJobStage(jobId, stage, options)
}