The browser should not own the only copy
An open tab, queue message or temporary variable can disappear while generation continues. Your application needs enough state to reconnect the user to the same task and private result. Keep account ownership and spending approval alongside operational status so another worker cannot accidentally recover a job for the wrong user.
What to do next
- 01
Persist before network transmission
Write the intended request and durable identifier first. After receiving a creation response, atomically add the returned job ID and poll route to that record.
- 02
Reconcile on startup
Load local records without terminal delivery states. For a known job, poll it; for a lost response with a saved identifier, recover the original submission using the unchanged body.
- 03
Resume delivery separately
Completed remote work may still need a local download or notification. Retry that delivery step without creating another image or video, and record when your user actually receives it.
A concrete example
Illustrative crash window: the app records its approved body and request identifier, sends creation, then crashes before saving the response. On restart the absence of remote_job_id is not proof that dispatch never happened. The worker uses the saved original identifier and unchanged request to recover the accepted task. In a different case where the job ID was saved but the browser update was lost, it polls that known job directly.
Restart reconciliation matrix
| Durable evidence after restart | Recovery operation | Do not do |
|---|---|---|
| Waiting record; no send attempt | Resume the approved local queue item | Claim remote acceptance without a response |
| Send attempted; response/job ID absent | Recover unchanged original submission with saved identity | Generate a fresh identifier to make the item look new |
| Known remote job; local file missing | Poll or retrieve existing work as appropriate | Submit a new paid generation to repair delivery |
Before you call it ready
- Task identity survives restarts.
- Ownership survives worker reassignment.
- Delivery retries do not recreate media.
When to stop or choose another method
If accepted tasks exist only in memory, pause new submissions and implement persistence before launch. Otherwise an ordinary restart can become lost output or duplicate spending.
