[object Object]

← back to Norma Platform

TK-10395: cap reel container poll at 12x4s so 3x-retry worst case < client 240s

564be77f5838b0911750002c333e7a06f5c51e32 · 2026-08-10 10:58:32 -0700 · Steve

Contrarian find: waitForContainer default 30x4s=120s/attempt made the 3-attempt
worst case ~375s > the reels-repo client 240s timeout, so the client could time
out MID-legit-retry and mislabel a still-in-flight post 'posted-unverified'.
Scope the reel poll to 12x4s=48s/attempt => 3x48+15s backoff=159s < 240s. Short
9:16 reels finish well under 48s. CODE-ONLY: going live needs a gated pm2 restart
of norma-instagram (memo'd to pending-approval).

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

Files touched

Diff

commit 564be77f5838b0911750002c333e7a06f5c51e32
Author: Steve <steve@designerwallcoverings.com>
Date:   Mon Aug 10 10:58:32 2026 -0700

    TK-10395: cap reel container poll at 12x4s so 3x-retry worst case < client 240s
    
    Contrarian find: waitForContainer default 30x4s=120s/attempt made the 3-attempt
    worst case ~375s > the reels-repo client 240s timeout, so the client could time
    out MID-legit-retry and mislabel a still-in-flight post 'posted-unverified'.
    Scope the reel poll to 12x4s=48s/attempt => 3x48+15s backoff=159s < 240s. Short
    9:16 reels finish well under 48s. CODE-ONLY: going live needs a gated pm2 restart
    of norma-instagram (memo'd to pending-approval).
    
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
 agents/instagram-agent/skills/reel.js | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/agents/instagram-agent/skills/reel.js b/agents/instagram-agent/skills/reel.js
index 9ba15f8..1b1e5d3 100644
--- a/agents/instagram-agent/skills/reel.js
+++ b/agents/instagram-agent/skills/reel.js
@@ -135,7 +135,12 @@ module.exports = async function reel(params) {
     containerId = await ig.createContainer(igUserId, accessToken, containerBody);
     console.log(`[${AGENT}] Reel container created: ${containerId} — waiting for processing... (attempt ${attempt}/${MAX_ATTEMPTS})`);
     try {
-      await ig.waitForContainer(containerId, accessToken);
+      // TK-10395 timing budget: cap the per-attempt poll so the WORST case (3 attempts all
+      // poll-timing-out) stays under the reels-repo client timeout (240s). 12 tries × 4s = 48s/attempt
+      // ⇒ 3×48s + 5s+10s backoff = 159s < 240s, so the client can't time out MID-retry and mislabel a
+      // still-in-flight post as 'posted-unverified' (contrarian find). Short 9:16 reels finish well
+      // under 48s; a container still not FINISHED at 48s is the stuck/failed mode we WANT to retry.
+      await ig.waitForContainer(containerId, accessToken, { tries: 12, delayMs: 4000 });
       break; // FINISHED — safe to publish
     } catch (e) {
       const transient = /2207076|Media upload has failed|did not finish processing/i.test(e.message || '');

← 9897011 TK-10395: bounded retry-on-2207076 in reel skill (Meta trans  ·  back to Norma Platform  ·  IG multi-account posting: registry + resolver + post-to CLI 6b3ec24 →