jackwener/OpenCLI · error · CommandExecutionError

Instagram private publish configure_sidecar timed out waitin

Error message

Instagram private publish configure_sidecar timed out waiting for video transcode

What it means

For multi-item sidecar publishes Instagram may return 202 or a 'transcode not finished yet' message while uploaded videos are still transcoding. publishSidecarWithRetry polls up to INSTAGRAM_PRIVATE_SIDECAR_TRANSCODE_ATTEMPTS times with INSTAGRAM_PRIVATE_SIDECAR_TRANSCODE_WAIT_MS sleeps; if the video is still not transcoded after the final attempt it throws this timeout error with the last response body (500 chars) as detail.

Source

Thrown at clis/instagram/_shared/private-publish.js:864

    for (let attempt = 0; attempt < INSTAGRAM_PRIVATE_SIDECAR_TRANSCODE_ATTEMPTS; attempt += 1) {
        const response = await input.fetcher('https://www.instagram.com/api/v1/media/configure_sidecar/', requestInit);
        const text = await response.text();
        let json = {};
        try {
            json = text ? JSON.parse(text) : {};
        }
        catch {
            throw new CommandExecutionError('Instagram private publish configure_sidecar returned invalid JSON');
        }
        if (!response.ok) {
            const detail = text ? ` ${text.slice(0, 500)}` : '';
            throw new CommandExecutionError(`Instagram private publish configure_sidecar failed: ${response.status}${detail}`);
        }
        const message = String(json?.message || '');
        if (response.status === 202
            || /transcode not finished yet/i.test(message)) {
            if (attempt >= INSTAGRAM_PRIVATE_SIDECAR_TRANSCODE_ATTEMPTS - 1) {
                throw new CommandExecutionError('Instagram private publish configure_sidecar timed out waiting for video transcode', text.slice(0, 500));
            }
            await waitMs(INSTAGRAM_PRIVATE_SIDECAR_TRANSCODE_WAIT_MS);
            continue;
        }
        if (String(json?.status || '').toLowerCase() === 'fail') {
            throw new CommandExecutionError('Instagram private publish configure_sidecar failed', message || text.slice(0, 500));
        }
        return { code: json?.media?.code };
    }
    throw new CommandExecutionError('Instagram private publish configure_sidecar failed');
}
export async function publishMediaViaPrivateApi(input) {
    const now = input.now ?? (() => Date.now());
    const clientSidecarId = String(now());
    const uploadIds = input.mediaItems.length > 1
        ? input.mediaItems.map((_, index) => String(now() + index + 1))
        : [String(now())];
    const fetcher = input.fetcher ?? ((url, init) => instagramPrivateApiFetch(input.page, url, init));

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Increase INSTAGRAM_PRIVATE_SIDECAR_TRANSCODE_ATTEMPTS or pass a slower waitMs so polling covers long transcodes.
  2. Compress/re-encode the video to a smaller resolution/bitrate so transcoding finishes faster.
  3. Retry the whole publish later — the upload succeeded; only the configure step timed out.
  4. Check the response detail embedded in the error for Instagram's specific transcode status.

Example fix

// before
await publishMediaViaPrivateApi({ mediaItems, apiContext });
// after
await publishMediaViaPrivateApi({ mediaItems, apiContext, waitMs: (ms) => new Promise(r => setTimeout(r, ms * 2)) });
Defensive patterns

Strategy: retry

Validate before calling

// Prefer smaller, pre-compressed videos
const stats = await fs.stat(videoPath);
if (stats.size > 100 * 1024 * 1024) throw new Error('Video too large; compress before sidecar publish');

Type guard

function isTranscodePending(response) {
  return response.status === 202 || /transcode not finished yet/i.test(response.message || '');
}

Try / catch

try {
  await publishMediaViaPrivateApi({ mediaItems, apiContext, waitMs });
} catch (e) {
  if (/timed out waiting for video transcode/.test(e.message)) {
    await sleep(120000); // upload succeeded; retry configure after delay
    return publishMediaViaPrivateApi({ mediaItems, apiContext, waitMs });
  }
  throw e;
}

Prevention

When it happens

Trigger: Every configure_sidecar attempt in the retry loop returned HTTP 202 or a message matching /transcode not finished yet/i, and the loop exhausted all attempts (attempt === INSTAGRAM_PRIVATE_SIDECAR_TRANSCODE_ATTEMPTS - 1).

Common situations: Very large or long videos that outlast the library's fixed polling budget; Instagram-side transcode backlog; configuring immediately after upload with no wait.

Understand the failure class

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/35acbddb208433a4. Report an issue: GitHub.