Marking an Onboarding Step Done From an Async Background Job
Some onboarding steps can't be completed by the request that starts them. Here is how to mark a step done safely once a background job finishes, instead of lying to the user up front.
Most onboarding steps complete in the same request that triggers them: a user clicks a button, the server does the work, the response says done. Some steps do not fit that shape. Importing a file, provisioning a resource, generating a report — the user's request only starts the work, and the work itself finishes seconds or minutes later in a background job, a queue worker, or a webhook callback from a third party. Marking that step complete has to happen somewhere else entirely, and getting that somewhere else wrong is how a checklist starts lying to users about what is actually done.
The step and the job are not the same event
The temptation is to mark the step complete the moment the request that kicked off the job returns successfully, because that is the only moment your onboarding code controls directly. It is also wrong: the request returning 202 means the job was accepted, not that it finished, and a user who sees a checked box while the import is still running will act on data that is not there yet, or file a ticket when it predictably fails a minute later.
The step's completion has to be driven by the job's own terminal state — success, specifically, not just the job existing or having started. That means the write that flips the step record happens from the worker or the webhook handler, not from the request handler that enqueued the work.
Where the completion write actually happens
The cleanest version is a direct call from the end of the job: the worker finishes its task, then writes the step completion in the same transaction or immediately after, so there is no separate process that can forget to check.
// pseudocode: worker-driven completion
async function runImportJob(jobID, accountID) {
const result = await doImport(jobID)
if (result.ok) {
await markStepComplete(accountID, 'import-data')
} else {
await markStepFailed(accountID, 'import-data', result.error)
}
}
If the job runs in a system you do not control — a third-party import, a payment provider's async confirmation — the same logic has to live in the webhook handler that receives its callback, with the same two outcomes: write success on success, write a visible failure state on failure, and do neither while the job is still in flight. See the docs for how step records are structured per account.
A step cannot stay stuck looking optimistic
The failure mode that generates the most support load is not the step staying incomplete — it is the step staying stuck in a state that looks like progress is happening when it is not. If the UI shows a spinner or an in-progress state for a step and the job that was supposed to resolve it has crashed, retried out, or silently timed out, the user has no signal that anything is wrong and no action to take.
A step that depends on a background job needs three states, not two: not started, in progress, and done — plus a distinct failed state that the UI can actually show, with something the user can do about it (retry, contact support, re-upload). A checklist that can only render done or not-done will quietly collapse failed into not-done, which is accurate in the data and misleading on the screen.
Idempotency matters more here than anywhere else in the checklist
Background jobs retry. Webhooks arrive more than once. A completion write that is not idempotent — one that increments a counter, sends a notification, or triggers a downstream effect every time it runs — will double up the moment the job's infrastructure does what job infrastructure does. The fix is the same one that applies to retrying any step completion: key the write by job ID or a request ID carried through from the start of the job, and make the handler a no-op if that key has already been recorded as processed.
// pseudocode: idempotent completion write
async function markStepComplete(accountID, step, jobID) {
const already = await wasProcessed(jobID)
if (already) return
await writeStepComplete(accountID, step)
await recordProcessed(jobID)
}
Telling the user without polling forever
The client side of this is simpler than it looks: once the step write happens server-side on job completion, the client just needs to learn about it. A short poll against the step status endpoint while the step is in progress, or a push over a connection you already have open, both work — what does not work is the client assuming success as soon as it gets a 202 from the request that started the job, which puts the client back in the same trap as the server-side shortcut this article is about.
What to measure instead of guessing
We do not have a measured figure for how long users tolerate a step sitting in progress before they assume it is broken and leave. That is worth instrumenting directly: time from job start to completion write, and whether the user re-opens or abandons the checklist while a step is in that in-progress state. If a meaningful share of users leave before the job resolves, the fix is either a faster job or a visible estimate of how long it takes — not a shorter checklist.
Related reading
For the general case of a step that fails rather than one that is merely slow, onboarding checklist error handling covers what the user should see. If the job is triggered by a retried request rather than a background worker, retrying a failed onboarding step safely covers the same idempotency problem from the request side. Try the live preview to see how step states render today.