Skip to content

fix(media): parallel combo fan-out for image and video strategies - #13852

Merged
diegosouzapw merged 3 commits into
diegosouzapw:release/v3.8.51from
opensource-elearning:fix/parallel-combo-fanout
Sep 29, 2026
Merged

diegosouzapw merged 3 commits into
diegosouzapw:release/v3.8.51from
opensource-elearning:fix/parallel-combo-fanout

Conversation

@opensource-elearning

Copy link
Copy Markdown
Contributor

Summary

Image and video combo strategies ran targets sequentially — a slow first target (e.g. AI Horde queue exhaustion, a provider that only fails after its full timeout) blocked every healthy sibling behind it. Both now fan out all targets concurrently via Promise.race against Promise.allSettled, so the first success wins immediately without waiting for slower siblings to finish. Terminal errors (400/401/403) surface when every target fails.

Changes

  • open-sse/services/imageCombo.ts — replaced sequential runImageComboTargets loop with a concurrent runTarget fan-out + Promise.race([firstSuccess, Promise.allSettled(tasks)]); first healthy success picks the winner, terminal errors surface last; added options?.generateImage for test injection; dropped the now-unused targetModel binding (lint gate).
  • open-sse/services/videoCombo.ts — same parallel fan-out pattern; preserved per-target prompt-optional (I2V) and credential-resolution variants.
  • tests/unit/combo/image-combo.test.ts — new test asserting parallel fan-out completes well before a slow first target's failure window.
  • changelog.d/fixes/media-combo-parallel-fanout.md — changelog fragment.

Test results

node --import tsx/esm --test tests/unit/combo/image-combo.test.ts — 10/10 pass.

Split out of #13098 per review feedback (the call_logs pid-id fix is now its own PR, #13851).

⚠️ base-red inherited: #12732
@diegosouzapw

The parallel fan-out in executeImageCombo is correct and kept as-is. The
same commit had removed runImageComboTargets, ImageComboTarget,
ImageComboDispatchResult and RunImageComboTargetsOptions from
imageCombo.ts entirely, but src/app/api/v1/images/edits/route.ts (not
touched by this PR) still imports and calls exactly those symbols
(runImageComboTargets, ImageComboDispatchResult) for its own combo
fallback loop (diegosouzapw#12547) -- a TS2305 build-time break on /v1/images/edits.
Restoring the shared sequential loop verbatim alongside the new parallel
executeImageCombo() so both paths keep working unchanged.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
@diegosouzapw
diegosouzapw merged commit 11719f5 into diegosouzapw:release/v3.8.51 Sep 29, 2026
9 of 16 checks passed
diegosouzapw added a commit that referenced this pull request Sep 29, 2026
…13852 image fan-out)

Maintainer decision for the v3.8.51 release: the parallel image fan-out from
#13852 dispatched (and billed) every leg on every request, even when the first
target answered healthily — exactly what the #12982 regression test guarded.
imageCombo.ts goes back to the shared runImageComboTargets loop (the next leg
runs only after the previous one fails), the #12982 'valid first-leg response
does not invoke later legs' test is restored unchanged, and the #13852 test
that asserted concurrent image dispatch is dropped with the behavior it
covered. The video fan-out from #13852 is untouched.
diegosouzapw added a commit that referenced this pull request Sep 29, 2026
…p, command-code none, contract drift) (#15111)

Release-captain base-red fix (v3.8.51 release PR #11442, unit shards 7-8): two production defects (GPT-5.1+ sampling stripped by a static rule from #14133; Command Code 'none' effort clamped although #14692 routes Responses bodies that accept it) plus contract propagations; image combos restored to sequential priority per the maintainer's decision (the #13852 image fan-out billed every leg on every request). Focused suites green, typecheck clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants