A mock interview on CogniPrep costs one credit. You record answers to five questions, a background job processes them, and feedback comes back by email. If the job cannot finish, the credit goes back.
That last sentence is the whole subject of this post, because "the credit goes back" has to mean exactly once, and a job that retries makes that harder than it sounds.
The shape of the run
It is a Trigger.dev task with ordinary retry settings:
export const processInterviewTask = task({
id: 'process-interview',
retry: {
maxAttempts: 3,
minTimeoutInMs: 2000,
maxTimeoutInMs: 30000,
factor: 2,
randomize: true,
},
run: async (payload) => { /* ... */ },
The run fetches the interview record, marks it processing, pulls the videos out of object storage, derives what the feedback step needs from each one, produces the feedback, persists it, deletes the source videos, and emails the user. Seven steps, three attempts, one credit.
Why the
Discussion
Take the lead—comment now
Lead the way—your insights can inspire others.