jackwener/OpenCLI · error · CommandExecutionError
Instagram image preview did not appear after upload
Error message
Instagram image preview did not appear after upload
What it means
waitForPreview polls the composer after upload to confirm Instagram shows a preview thumbnail of the uploaded media. If after all attempts the preview never appears, it saves /tmp/instagram_post_preview_debug.png and throws this error. It signals the upload never took effect from Instagram's perspective.
Source
Thrown at clis/instagram/post.js:782
})()
`);
return !!result?.ok;
}
async function waitForPreview(page, maxWaitSeconds = 12) {
const attempts = Math.max(1, Math.ceil(maxWaitSeconds));
for (let attempt = 0; attempt < attempts; attempt++) {
const state = await inspectUploadStage(page);
if (state.state === 'preview')
return;
if (state.state === 'failed') {
await page.screenshot({ path: '/tmp/instagram_post_preview_debug.png' });
throw makeUploadFailure('Inspect /tmp/instagram_post_preview_debug.png. ' + (state.detail || ''));
}
if (attempt < attempts - 1)
await page.wait({ time: 1 });
}
await page.screenshot({ path: '/tmp/instagram_post_preview_debug.png' });
throw new CommandExecutionError('Instagram image preview did not appear after upload', 'The selected file input may not match the active composer; inspect /tmp/instagram_post_preview_debug.png');
}
async function waitForPreviewMaybe(page, maxWaitSeconds = 4) {
const attempts = Math.max(1, Math.ceil(maxWaitSeconds * 2));
for (let attempt = 0; attempt < attempts; attempt++) {
const state = await inspectUploadStage(page);
if (state.state !== 'pending')
return state;
if (attempt < attempts - 1)
await page.wait({ time: 0.5 });
}
return { state: 'pending' };
}
export function buildClickActionJs(labels, scope = 'any') {
return `
((labels, scope) => {
const isVisible = (el) => {
if (!(el instanceof HTMLElement)) return false;
const style = window.getComputedStyle(el);View on GitHub (pinned to 49907e53dc)
Solutions
- Inspect /tmp/instagram_post_preview_debug.png to see what the composer actually shows
- Re-run and allow more wait time for large files or slow connections
- Verify the media file meets Instagram's format/size limits before retrying
- Re-resolve upload selectors in case the first selector targeted a non-composer input
- Log in again if a session interstitial appears in the debug screenshot
Example fix
// before await postImage(page, hugeFile); // 8MB, slow link, preview never appears // after const stat = fs.statSync(hugeFile); if (stat.size > 4 * 1024 * 1024) await compressImage(hugeFile); await postImage(page, hugeFile);
Defensive patterns
Strategy: retry
Validate before calling
const stat = fs.statSync(filePath);
if (!/^\.(jpe?g|png)$/i.test(path.extname(filePath)) || stat.size > 8 * 1024 * 1024) {
throw new Error('Media not Instagram-compatible: ' + filePath);
} Try / catch
try {
await postImage(page, file);
} catch (e) {
if (String(e.message).includes('preview did not appear')) {
// debug shot is at /tmp/instagram_post_preview_debug.png
await page.wait({ time: 5 });
return postImage(page, file); // one slower retry
}
throw e;
} Prevention
- Pre-validate media format and size against Instagram limits
- Allow generous waits for large files or slow links
- Check the debug screenshot after each failure before changing code
When it happens
Trigger: executeUiInstagramPost -> waitForPreview exhausts its polling attempts with inspectUploadStage never leaving 'pending'/absent state; also thrown via makeUploadFailure path when inspectUploadStage reports a failed upload stage with detail.
Common situations: Wrong file input selected (selector matches a hidden/unused input), Instagram silently rejecting the file (format, size, aspect ratio), slow network upload not finished within the wait window, or a session/2FA interstitial blocking the composer.
Related errors
- Instagram action button not found: ${labels.join(' / ')}
- Instagram caption editor did not appear
- Failed to fill Instagram caption
- Instagram action button not found: ${labels.join(' / ')}
- settings click failed
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a38289fa508ec554.
Report an issue: GitHub.