{"record":{"id":"35acbddb208433a4","repo":"jackwener/OpenCLI","slug":"instagram-private-publish-configure-sidecar-timed","errorCode":null,"errorMessage":"Instagram private publish configure_sidecar timed out waiting for video transcode","messagePattern":"Instagram private publish configure_sidecar timed out waiting for video transcode","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/_shared/private-publish.js","lineNumber":864,"sourceCode":"    for (let attempt = 0; attempt < INSTAGRAM_PRIVATE_SIDECAR_TRANSCODE_ATTEMPTS; attempt += 1) {\n        const response = await input.fetcher('https://www.instagram.com/api/v1/media/configure_sidecar/', requestInit);\n        const text = await response.text();\n        let json = {};\n        try {\n            json = text ? JSON.parse(text) : {};\n        }\n        catch {\n            throw new CommandExecutionError('Instagram private publish configure_sidecar returned invalid JSON');\n        }\n        if (!response.ok) {\n            const detail = text ? ` ${text.slice(0, 500)}` : '';\n            throw new CommandExecutionError(`Instagram private publish configure_sidecar failed: ${response.status}${detail}`);\n        }\n        const message = String(json?.message || '');\n        if (response.status === 202\n            || /transcode not finished yet/i.test(message)) {\n            if (attempt >= INSTAGRAM_PRIVATE_SIDECAR_TRANSCODE_ATTEMPTS - 1) {\n                throw new CommandExecutionError('Instagram private publish configure_sidecar timed out waiting for video transcode', text.slice(0, 500));\n            }\n            await waitMs(INSTAGRAM_PRIVATE_SIDECAR_TRANSCODE_WAIT_MS);\n            continue;\n        }\n        if (String(json?.status || '').toLowerCase() === 'fail') {\n            throw new CommandExecutionError('Instagram private publish configure_sidecar failed', message || text.slice(0, 500));\n        }\n        return { code: json?.media?.code };\n    }\n    throw new CommandExecutionError('Instagram private publish configure_sidecar failed');\n}\nexport async function publishMediaViaPrivateApi(input) {\n    const now = input.now ?? (() => Date.now());\n    const clientSidecarId = String(now());\n    const uploadIds = input.mediaItems.length > 1\n        ? input.mediaItems.map((_, index) => String(now() + index + 1))\n        : [String(now())];\n    const fetcher = input.fetcher ?? ((url, init) => instagramPrivateApiFetch(input.page, url, init));","sourceCodeStart":846,"sourceCodeEnd":882,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/_shared/private-publish.js#L846-L882","documentation":"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.","triggerScenarios":"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).","commonSituations":"Very large or long videos that outlast the library's fixed polling budget; Instagram-side transcode backlog; configuring immediately after upload with no wait.","solutions":["Increase INSTAGRAM_PRIVATE_SIDECAR_TRANSCODE_ATTEMPTS or pass a slower waitMs so polling covers long transcodes.","Compress/re-encode the video to a smaller resolution/bitrate so transcoding finishes faster.","Retry the whole publish later — the upload succeeded; only the configure step timed out.","Check the response detail embedded in the error for Instagram's specific transcode status."],"exampleFix":"// before\nawait publishMediaViaPrivateApi({ mediaItems, apiContext });\n// after\nawait publishMediaViaPrivateApi({ mediaItems, apiContext, waitMs: (ms) => new Promise(r => setTimeout(r, ms * 2)) });","handlingStrategy":"retry","validationCode":"// Prefer smaller, pre-compressed videos\nconst stats = await fs.stat(videoPath);\nif (stats.size > 100 * 1024 * 1024) throw new Error('Video too large; compress before sidecar publish');","typeGuard":"function isTranscodePending(response) {\n  return response.status === 202 || /transcode not finished yet/i.test(response.message || '');\n}","tryCatchPattern":"try {\n  await publishMediaViaPrivateApi({ mediaItems, apiContext, waitMs });\n} catch (e) {\n  if (/timed out waiting for video transcode/.test(e.message)) {\n    await sleep(120000); // upload succeeded; retry configure after delay\n    return publishMediaViaPrivateApi({ mediaItems, apiContext, waitMs });\n  }\n  throw e;\n}","preventionTips":["Compress videos before upload to shorten transcoding.","Increase INSTAGRAM_PRIVATE_SIDECAR_TRANSCODE_ATTEMPTS or pass a slower waitMs for long videos.","Schedule video publishes away from peak Instagram load.","Check the error detail body for Instagram's transcode progress info."],"tags":["instagram","timeout","transcode","video","retry"],"backgroundTag":"polling-timeout","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}