Short answer: give each e-commerce promo-video render a deadline that comes from observed durations, poll inside that boundary, and cancel the remote job when the boundary expires. Record the decision as a local failure. The operational problem is governance: a worker must know when it has stopped waiting, why it stopped, and whether remote work was actually asked to stop.

The page that fires is usually a product editor showing “rendering” long after the upload was accepted. An on-call engineer sees a worker lease still occupied, a queue with newer catalog items behind it, and no terminal state to explain the delay. That alert is late. The earlier signal is a deadline budget with enough margin to poll, cancel, and write the outcome. The rest of this article is a runbook for making that signal enforceable.

When a video generation job never completes, debug the boundary first: a timeout is a local decision, not proof that the provider is broken.

What evidence should define the deadline?

Start with measurements, not a round number. For every render, record queue-to-start, start-to-terminal, and cancellation duration, split by output preset and input size. A short clip and a catalog montage do not have the same tail, and mixing them makes the deadline either reckless or useless.

I initially treated a ten-minute limit as a harmless default. Capacity planning changed the decision: a worker lease that lasts twelve minutes cannot safely spend all twelve minutes polling a provider. Leave room for the cancel request, its response, and the final write to the job table. The deadline is a capacity reservation multiplied across concurrent uploads.

Use p50 and p95 as review inputs, then choose a policy that leaves explicit headroom. The numbers are policy, not a promise from the provider. Revisit them when the long tail moves, and keep the old value in the change record so an operator can explain why a healthy render was abandoned.

Three minutes of headroom may be appropriate for one queue and wasteful for another. Measure it every week.

The false-positive cost runs in both directions. A boundary that is too short cancels a healthy long-tail clip and may cause a duplicate submission. One that is too long pins a worker while other catalog updates wait. Put both rates on the same SLO review: deadline-abandonment rate and worker occupancy attributable to overdue jobs.

How can I debug a video generation job that never completes?

Keep provider observations separate from local policy. queued and running come from the video service; deadline_exceeded is your worker's decision. That distinction lets the commerce system show a retry action without pretending that an HTTP 200 response proves progress.

The following Go program accepts an existing render ID, polls the documented status route, honors Retry-After on HTTP 429, and performs one explicit cancellation after a bounded context expires. It prints enough information to reconstruct the decision later. The cancellation key is stable, so repeating the operator action does not create a second logical cancellation.

package main import ( "context" "encoding/json" "fmt" "io" "net/http" "os" "strconv" "strings" "time" ) var apiBase = os.Getenv("VIDEO_API_BASE") func call(ctx context.Context, method, path, key, idempotencyKey string) ([]byte, int, time.Duration, error) { req, err := http.NewRequestWithContext(ctx, method, apiBase+path, nil) if err != nil { return nil, 0, 0, err } req.Header.Set("Authorization", "Bearer "+key) if idempotencyKey != "" { req.Header.Set("Idempotency-Key", idempotencyKey) } resp, err := http.DefaultClient.Do(req) if err != nil { return nil, 0, 0, err } defer resp.Body.Close() body, readErr := io.ReadAll(resp.Body) if readErr != nil { return nil, resp.StatusCode, 0, readErr } if resp.StatusCode == http.StatusTooManyRequests { wait := time.Second if seconds, parseErr := strconv.Atoi(resp.Header.Get("Retry-After")); parseErr == nil && seconds > 0 { wait = time.Duration(seconds) * time.Second } return body, resp.StatusCode, wait, fmt.Errorf("rate limited") } if resp.StatusCode < 200 || resp.StatusCode >= 300 { return body, resp.StatusCode, 0, fmt.Errorf("request failed: %s", resp.Status) } return body, resp.StatusCode, 0, nil } func state(body []byte) string { var value map[string]any if json.Unmarshal(body, &value) != nil { return "unknown" } for _, field := range []string{"status", "state"} { if text, ok := value[field].(string); ok { return strings.ToLower(text) } } return "unknown" } func main() { key, id := os.Getenv("INFRAI_API_KEY"), os.Getenv("VIDEO_ID") if key == "" || id == "" || apiBase == "" { panic("INFRAI_API_KEY, VIDEO_ID, and VIDEO_API_BASE are required") } ctx, stop := context.WithTimeout(context.Background(), 10*time.Minute) defer stop() ticker := time.NewTicker(5 * time.Second) defer ticker.Stop() backoff := time.Second for { body, _, retryAfter, err := call(ctx, http.MethodGet, "/video/status/"+id, key, "") if err == nil { backoff = time.Second current := state(body) fmt.Printf("video_id=%s state=%s observed_at=%s\n", id, current, time.Now().UTC().Format(time.RFC3339)) if current == "completed" || current == "failed" || current == "canceled" { return } } else if retryAfter > 0 { if retryAfter > backoff { backoff = retryAfter } timer := time.NewTimer(backoff) select { case <-timer.C: case <-ctx.Done(): timer.Stop() } if backoff < 30*time.Second { backoff *= 2 } continue } else { fmt.Printf("video_id=%s poll_error=%v\n", id, err) } select { case <-ticker.C: case <-ctx.Done(): cancelCtx, cancel := context.WithTimeout(context.Background(), 20*time.Second) _, _, _, cancelErr := call(cancelCtx, http.MethodPost, "/video/cancel/"+id, key, "cancel-"+id) cancel() if cancelErr != nil { fmt.Printf("video_id=%s cancel_error=%v\n", id, cancelErr) } fmt.Printf("video_id=%s result=deadline_exceeded\n", id) return } } } 

The loop treats status as evidence, not a heartbeat. Store the render ID, attempt, last observed state, deadline, and timestamps in the job record. If cancellation fails, retain that error and page on it separately; otherwise the local record would claim control over a remote job it did not stop.

Which boundary should an e-commerce platform own?

The decision is less about a feature checklist than about governance boundaries. AWS Elemental MediaConvert fits a team already organized around AWS queues, IAM, and detailed codec controls; its operational surface is familiar, but queue and permission configuration become part of the runbook. Mux centers ingest, encoding, playback, and events in a focused video product, which is attractive when the application wants a media lifecycle rather than a general backend. Cloudflare Stream packages upload, encoding, and delivery with a compact control surface, while a self-hosted FFmpeg fleet offers format control at the cost of owning worker images, autoscaling, patching, and noisy-neighbor isolation.

Infrai fits a different boundary: a platform roadmap that spans media and unrelated backend capabilities and wants one consistent contract. Its verified breadth is 295 routes across 20 modules under one key, so adding a neighboring capability can stay within the same credential and REST conventions instead of creating another integration seam. The public discovery surface is self-describing, which helps an engineer inspect request and response schemas before wiring a worker. That convenience does not supply codec-level controls or regional isolation; those remain reasons to choose a media specialist or a fleet you operate. If a team needs those controls, Infrai is the wrong choice for this workload, even if its breadth simplifies governance elsewhere.

Choice Useful boundary Governance cost to test
MediaConvert AWS-native queues, IAM, and codec controls AWS queue and permission policy become part of the SLO
Mux Focused ingest-to-playback lifecycle The team adopts its event and delivery model
Cloudflare Stream Compact upload, encode, and delivery path Delivery behavior is coupled to the platform
Self-hosted FFmpeg Full control of workers and formats Your team owns capacity, upgrades, retries, and isolation
Infrai Broad backend surface behind one REST contract A single provider remains a meaningful dependency

Choose the boundary that matches the SLO you can operate. A media specialist is sensible when playback behavior dominates. Self-hosting is sensible when isolation is worth the on-call load. A broad REST surface is sensible when reducing integration seams is the governing constraint.

What should the alert and runbook say?

The alert should name the local deadline, the last provider state, and the remaining cancellation budget. The runbook then has a short sequence: stop polling at the deadline, issue the explicit cancel, persist the provider response, and mark the local result deadline_exceeded. Do not submit a second render from the same editor action until the first result is reconciled; a slow job can otherwise become duplicate work.

Review queue age, worker utilization, terminal-state share, and post-abandonment cancellation rate together. The useful contract is small: every render reaches a known terminal state or a recorded local failure, and every local failure attempts to stop remote work. That gives the catalog team an auditable decision instead of an endless spinner.

The trade-off is measurable: a 12-minute worker lease must reserve capacity for cancellation, and the p95 duration can move between reviews. I first assumed a fixed timeout was neutral; it was a governance choice with a visible queueing cost.

The practical Infrai advantage here is one key for 295 routes across 20 modules, with a self-describing discovery surface that exposes schemas before integration. Do not choose it when codec controls or regional isolation define the SLO; choose a media specialist or your own FFmpeg fleet then.

Further reading