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
- 1startHeroFor() posts the generation request and stores hero_task_id, hero_task_at and hero_style.
- 2collectPendingHeroes() finds posts with a task id and no hero URL, checks each, and stores finished images durably.
- 3A failure clears the task id and writes the reason to gen_error, so it can be retried rather than silently retried forever.
- 4A task older than six hours is abandoned with 'generation never finished — try again'.
- 5The panel's own button still uses the blocking version, because a person is watching.
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."
- A slow image generation blocked a serverless invocation and held back finished posts.
- A lost generation task left a post waiting forever.
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 →