Resumable image generation

Image jobs are started and parked, then collected on a later pass — so a slow picture costs nothing and never fails a post.

What it is

The outbox pattern applied to image generation. startHeroFor() kicks off the task and writes its id and timestamp onto the post without waiting. collectPendingHeroes() runs at the top of the content and publish crons, checks up to twenty in-flight tasks, stores any that finished, records any that failed, and abandons anything older than six hours with a reason the panel can show.

Also called: image takes too long · background image jobs · hero outbox

See it
Resumable image generation
Won
37%
Avg cycle
21d
Pipeline
$419k
JanSep
A timeline: task started on pass 1, still generating, collected and stored on pass 2, post publishes on pass 3. Sample data — no customer information appears here.
How it works
  1. 1startHeroFor() posts the generation request and stores hero_task_id, hero_task_at and hero_style.
  2. 2collectPendingHeroes() finds posts with a task id and no hero URL, checks each, and stores finished images durably.
  3. 3A failure clears the task id and writes the reason to gen_error, so it can be retried rather than silently retried forever.
  4. 4A task older than six hours is abandoned with 'generation never finished — try again'.
  5. 5The panel's own button still uses the blocking version, because a person is watching.
Why we built it

The comment records the incident: "kie.ai routinely takes longer than any single serverless invocation should wait — during the autopilot build a one-word prompt was still GENERATING at three minutes. Blocking on it burned an invocation AND made the publisher hold back finished posts for an image that was simply still in flight. So: start the task, park its id on the post, and collect it on the next pass… A slow image now costs nothing and never fails a post — it just isn't ready this minute." The six-hour abandonment exists because "a post waiting forever on a ghost is worse than a post that reports it needs another try."

The problem
  • A slow image generation blocked a serverless invocation and held back finished posts.
  • A lost generation task left a post waiting forever.
Sound familiar?
What you get
A slow image delays a post by one pass instead of failing it
Abandoned tasks are reported so they can be retried
The interactive path still blocks, because someone is watching it

See it on your own jobs

Twenty minutes, your numbers, no slide deck. We’ll build one of your real buildings in front of you and send you the estimate link at the end — yours to keep either way.

or keep browsing features →