{"record":{"id":"972d9fc39fa39d6c","repo":"tonhowtf/omniget","slug":"o-instagram-demorou-demais-para-processar-a-midia","errorCode":null,"errorMessage":"o Instagram demorou demais para processar a midia","messagePattern":"o Instagram demorou demais para processar a midia","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/instagram/publish.rs","lineNumber":588,"sourceCode":"}\n\nasync fn wait_container(http: &reqwest::Client, id: &str, token: &str) -> anyhow::Result<()> {\n    for _ in 0..40 {\n        let st = graph_get(\n            http,\n            &format!(\n                \"{}/{}?fields=status_code,status&access_token={}\",\n                GRAPH, id, token\n            ),\n        )\n        .await?;\n        match s(&st, \"status_code\").as_str() {\n            \"FINISHED\" => return Ok(()),\n            \"ERROR\" | \"EXPIRED\" => return Err(anyhow!(\"o container falhou: {}\", s(&st, \"status\"))),\n            _ => tokio::time::sleep(std::time::Duration::from_secs(5)).await,\n        }\n    }\n    Err(anyhow!(\"o Instagram demorou demais para processar a midia\"))\n}\n\n/// Publica pela API oficial. `req.files` são URLs públicas.\npub async fn publish_graph(\n    auth: &GraphAuth,\n    req: &PublishRequest,\n    progress: &super::super::ProgressFn,\n    job: &str,\n) -> anyhow::Result<PublishResult> {\n    let id = format!(\"ig:{}\", job);\n    let http = super::super::client()?;\n    let token = auth.access_token.trim().to_string();\n    let user = auth.ig_user_id.trim().to_string();\n    if token.is_empty() || user.is_empty() {\n        return Err(anyhow!(\"informe o token e o ID da conta do Instagram\"));\n    }\n    if req.files.is_empty() || !req.files.iter().all(|f| f.starts_with(\"http\")) {\n        return Err(anyhow!(","sourceCodeStart":570,"sourceCodeEnd":606,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/instagram/publish.rs#L570-L606","documentation":"wait_container loops polling the container status every 5 seconds; if the loop exhausts its bounded number of iterations without reaching FINISHED, it gives up with \"o Instagram demorou demais para processar a midia\" (Instagram took too long to process the media). It is a client-side timeout on the async container-processing pipeline.","triggerScenarios":"publish_graph creates a video container whose status_code stays in IN_PROGRESS for the full polling budget of wait_container (5-second sleeps until the loop ends).","commonSituations":"Large/slow-transcoding videos during Instagram peak load; container stuck in PROCESSING due to an overloaded or mis-encoded source file.","solutions":["Retry the publish later — processing delay is often transient on Instagram's side","Reduce video size/duration and re-encode with Instagram-recommended settings so transcoding finishes faster","If delays are routine, raise the polling budget/timeout in wait_container (more iterations) while keeping the 5s interval"],"exampleFix":"// before\nfor _ in 0..N_POLLS { ... } // too few for long videos\n// after\nfor _ in 0..(N_POLLS * 4) {\n    // same 5s poll loop; longer overall budget\n}","handlingStrategy":"retry","validationCode":"// prefer smaller, pre-encoded assets so processing completes within the polling budget\nassert!(file_size_mb <= 100.0 && duration_secs <= 90.0);","typeGuard":null,"tryCatchPattern":"match wait_container(&http, &id, &token).await {\n    Err(e) if e.to_string().contains(\"demorou demais\") => {\n        tokio::time::sleep(Duration::from_secs(60)).await;\n        wait_container(&http, &id, &token).await // retry poll once more\n    }\n    r => r,\n}","preventionTips":["Pre-transcode videos to Instagram-friendly settings before creating the container","Avoid publishing very large files during peak hours when possible","Allow a generous polling budget for videos; keep polling even after slow starts"],"tags":["instagram","timeout","media-processing"],"backgroundTag":"request-timeout","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}