feat(engine): add opt-in image timeout and scene-paint hedging

IMAGE_TIMEOUT_MS sets a per-attempt hard deadline (AbortSignal.timeout);
IMAGE_HEDGE_MS races a second identical scene-paint request when the
first is still pending past the threshold. Both default to OFF when
unset, preserving historical behavior for self-hosted deploys.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
yuanzonghao
2026-06-13 11:21:47 +08:00
parent c4ffc16498
commit e68e7e1690
8 changed files with 223 additions and 28 deletions
+6 -1
View File
@@ -87,7 +87,12 @@ export async function renderCharacterPortrait(
visualDescription,
styleGuide,
);
const { imageUrl, imageUuid } = await generateImage(config.image, prompt);
// Portraits get the hard timeout but are never hedged — a scene already
// runs several portrait paints in parallel, and hedging those would push
// burst concurrency past Runware's recommended 2-4 in-flight requests.
const { imageUrl, imageUuid } = await generateImage(config.image, prompt, {
timeoutMs: config.imageTimeoutMs,
});
return { basePortraitUrl: imageUrl, basePortraitUuid: imageUuid };
} catch (err) {
const msg = err instanceof Error ? err.message : String(err);