[object Object]

← back to Interiordesignershowroom

TK-10402: AbortSignal 30s timeout + ok-check on Flux image download (inert path hardening)

1a8e5c70f4196359640052a8ee357d0220957f7b · 2026-08-27 11:08:04 -0700 · Steve Abrams

Prevents a hung Replicate CDN download from wedging the batch indefinitely;
adds an explicit HTTP-status check. No behavior change on the funded path,
no spend (fallback stays inert until a REPLICATE_API_TOKEN is routed).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Files touched

Diff

commit 1a8e5c70f4196359640052a8ee357d0220957f7b
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Thu Aug 27 11:08:04 2026 -0700

    TK-10402: AbortSignal 30s timeout + ok-check on Flux image download (inert path hardening)
    
    Prevents a hung Replicate CDN download from wedging the batch indefinitely;
    adds an explicit HTTP-status check. No behavior change on the funded path,
    no spend (fallback stays inert until a REPLICATE_API_TOKEN is routed).
    
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
 lib/scene-providers/replicate-flux.js | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/scene-providers/replicate-flux.js b/lib/scene-providers/replicate-flux.js
index 6038c2e..1b0f265 100644
--- a/lib/scene-providers/replicate-flux.js
+++ b/lib/scene-providers/replicate-flux.js
@@ -73,7 +73,9 @@ async function generateScene(opts = {}) {
   const imgUrl = Array.isArray(out.output) ? out.output[0] : out.output;
   if (!imgUrl) throw new Error('no image returned');
 
-  const buf = Buffer.from(await (await fetch(imgUrl)).arrayBuffer());
+  const dl = await fetch(imgUrl, { signal: AbortSignal.timeout(30000) });
+  if (!dl.ok) throw new Error('image download failed: HTTP ' + dl.status);
+  const buf = Buffer.from(await dl.arrayBuffer());
   const id = crypto.createHash('sha1').update(String(Date.now()) + Math.random()).digest('hex').slice(0, 16);
   const file = `${id}.png`;
   fs.writeFileSync(path.join(OUT_DIR, file), buf);

← 797a158 chore: refactor review (clean, no changes), v0.5.0 (session  ·  back to Interiordesignershowroom  ·  TK-10402: route guide heroes through the SCENE_PROVIDER disp abbea82 →