jackwener/OpenCLI · error · CommandExecutionError
Instagram reel preview did not appear after upload
Error message
Instagram reel preview did not appear after upload
What it means
waitForVideoPreview waits up to maxWaitSeconds*2 half-second polls for the upload to reach the 'preview' DOM state. When the loop exhausts without success, it captures a debug screenshot to /tmp/instagram_reel_preview_debug.png and throws this timeout error with the last visible dialog text. It means the upload never failed explicitly but also never reached the preview stage in time.
Solutions
- Open /tmp/instagram_reel_preview_debug.png — it shows the actual page state at timeout.
- Increase maxWaitSeconds for large files or slow networks so polling outlasts the real upload time.
- If the screenshot shows a captcha/login/consent dialog, resolve that session issue; refresh cookies or re-login.
- Update the stage-detection selectors in buildInspectUploadStageJs to match the current Instagram DOM.
- Retry the upload; transient stalls often succeed on a second attempt.
Example fix
// before await waitForVideoPreview(page, 20); // 20s too short for 500MB upload // after await waitForVideoPreview(page, 120); // allow slow uploads to finish
Defensive patterns
Strategy: retry
Validate before calling
// Sanity-check budget before waiting: estimate upload time const sizeMb = fs.statSync(videoPath).size / 1e6; const estSeconds = sizeMb / (uplinkMbps / 8); const maxWaitSeconds = Math.max(30, Math.ceil(estSeconds * 2));
Type guard
function isStillUploading(r) {
return !!r && typeof r === 'object' && r.state !== 'preview' && r.state !== 'failed';
} Try / catch
try {
await waitForVideoPreview(page, maxWaitSeconds);
} catch (err) {
if (String(err.message).includes('preview did not appear')) {
// Screenshot already saved at /tmp/instagram_reel_preview_debug.png — inspect it,
// handle any blocking dialog, then retry the upload
} else throw err;
} Prevention
- Open /tmp/instagram_reel_preview_debug.png on every occurrence before changing code
- Scale maxWaitSeconds to file size and connection speed
- Keep stage-detection selectors updated against current Instagram DOM
- Clear unexpected dialogs (captcha/login/consent) before starting the flow
When it happens
Trigger: All polling attempts in waitForVideoPreview complete while buildInspectUploadStageJs() keeps returning a non-'preview', non-'failed' state (e.g. still uploading, stuck progress bar, unexpected UI).
Common situations: Very large or slow-to-upload video exceeding maxWaitSeconds on slow connections; Instagram A/B UI changes so the preview selector no longer matches; a hidden captcha/2FA/consent dialog blocking progression; heavy page load starving the upload.
Related errors
- Instagram reel editor did not appear
- Instagram reel upload failed
- Instagram post share confirmation did not appear
- Instagram reel editor did not appear
- Instagram reel share confirmation did not appear
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/6eba499fb0f0c4a0.
Report an issue: GitHub.
Appendix: source
Thrown at clis/instagram/reel.js:220
if (result?.count === null || result?.count === undefined)
return null;
return Number(result.count);
}
async function waitForVideoPreview(page, maxWaitSeconds = 20) {
let lastDetail = '';
for (let attempt = 0; attempt < maxWaitSeconds * 2; attempt += 1) {
const result = await page.evaluate(buildInspectUploadStageJs());
lastDetail = String(result?.detail || '').trim();
if (result?.state === 'preview')
return;
if (result?.state === 'failed') {
throw new CommandExecutionError('Instagram reel upload failed', result.detail ? `Instagram rejected the reel upload: ${result.detail}` : 'Instagram rejected the reel upload before the preview stage');
}
if (attempt < maxWaitSeconds * 2 - 1)
await page.wait({ time: 0.5 });
}
await page.screenshot({ path: '/tmp/instagram_reel_preview_debug.png' });
throw new CommandExecutionError('Instagram reel preview did not appear after upload', lastDetail
? `Inspect /tmp/instagram_reel_preview_debug.png. Last visible dialog text: ${lastDetail}`
: 'Inspect /tmp/instagram_reel_preview_debug.png for the upload state');
}
async function clickAction(page, labels, scope = 'any') {
const result = await page.evaluate(buildClickActionJs(labels, scope));
if (!result?.ok) {
throw new CommandExecutionError(`Instagram action button not found: ${labels.join(' / ')}`);
}
return result.label || labels[0] || '';
}
async function clickActionMaybe(page, labels, scope = 'any') {
const result = await page.evaluate(buildClickActionJs(labels, scope));
return !!result?.ok;
}
function buildInspectReelStageJs() {
return `
(() => {
const isVisible = (el) => {View on GitHub (pinned to 49907e53dc)