jackwener/OpenCLI · error · CommandExecutionError
Midjourney reference upload fallback lost its transfer buffe
Error message
Midjourney reference upload fallback lost its transfer buffer
What it means
While streaming the file to the in-page transfer buffer in base64 chunks, each append is verified: the page-side code re-reads window[uploadKey][fileIndex] and pushes the chunk. If any append returns false — the buffer entry vanished or its chunks array is gone — this CommandExecutionError is thrown, since the partial upload would be corrupt.
Source
Thrown at clis/midjourney/utils.js:1016
const files = window[key];
if (!Array.isArray(files)) return -1;
files.push({ ...item, chunks: [] });
return files.length - 1;
}, uploadKey, descriptor));
if (!Number.isInteger(fileIndex) || fileIndex < 0) {
throw new CommandExecutionError('Midjourney reference upload fallback could not initialize its transfer buffer');
}
const base64 = (await fs.readFile(localPath)).toString('base64');
const chunkSize = 96 * 1024;
for (let offset = 0; offset < base64.length; offset += chunkSize) {
const chunk = base64.slice(offset, offset + chunkSize);
const appended = unwrapEvaluateResult(await page.evaluate((key, index, value) => {
const file = window[key]?.[index];
if (!file || !Array.isArray(file.chunks)) return false;
file.chunks.push(value);
return true;
}, uploadKey, fileIndex, chunk));
if (!appended) throw new CommandExecutionError('Midjourney reference upload fallback lost its transfer buffer');
}
}
const result = unwrapEvaluateResult(await page.evaluate((key) => {
const input = document.querySelector('[data-opencli-image-input="1"]');
if (!(input instanceof HTMLInputElement)) return { ok: false, reason: 'image file input not found' };
const transfer = new DataTransfer();
for (const item of window[key] || []) {
const binary = atob(item.chunks.join(''));
const bytes = new Uint8Array(binary.length);
for (let index = 0; index < binary.length; index += 1) bytes[index] = binary.charCodeAt(index);
transfer.items.add(new File([bytes], item.name, { type: item.mime }));
}
input.files = transfer.files;
const nativeEvent = new Event('change', { bubbles: true });
const propsKey = Object.keys(input).find((key) => key.startsWith('__reactProps$'));
if (propsKey && typeof input[propsKey]?.onChange === 'function') {
input[propsKey].onChange({ target: input, currentTarget: input, nativeEvent });
} else {View on GitHub (pinned to 49907e53dc)
Solutions
- Retry the upload; ensure no navigation or reload happens during the transfer
- Avoid triggering other actions in the page while the upload is streaming
- Use smaller images (fewer chunks, shorter transfer window) to reduce exposure
- Update the CLI if the page environment changed how window state persists
Example fix
// before uploadPromise = uploadReferences(page, refs); await page.reload(); // wipes window buffer mid-transfer // after await uploadReferences(page, refs); // wait for transfer to finish first await page.reload();
Defensive patterns
Strategy: retry
Validate before calling
// before starting, ensure the buffer exists and will not be disturbed
const ready = await page.evaluate((k) => Array.isArray(window[k]) && window[k].length > 0, uploadKey);
if (!ready) throw new Error('Transfer buffer missing before chunked upload'); Type guard
null
Try / catch
try {
await uploadLocalReference(page, localPath, descriptor);
} catch (e) {
if (String(e.message).includes('lost its transfer buffer')) {
await page.reload();
await uploadLocalReference(page, localPath, descriptor); // restart transfer cleanly
} else throw e;
} Prevention
- Keep uploads atomic: no clicks, reloads, or route changes while chunks stream
- Prefer smaller images — fewer chunks means a smaller failure window
- Restart the whole transfer on buffer loss; partial state cannot be resumed
- Serialize uploads; concurrent attempts can clobber the shared window key
When it happens
Trigger: The page navigated or the execution context was destroyed mid-transfer, another script cleared window[uploadKey] between chunks, or the file entry was replaced with an object lacking a chunks array.
Common situations: Large files taking many chunks while the SPA re-renders or the user clicks something that reloads state, HMR/dev reloads clearing window state, or concurrent upload attempts overwriting the same key.
Related errors
- Midjourney reference upload fallback could not initialize it
- Unexpected 12306 probe: ${JSON.stringify(probe)}
- Waiting for 12306 tk auth cookie
- amazon.com
- Unexpected Amazon probe: ${JSON.stringify(probe)}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/49db24ef4424c9e1.
Report an issue: GitHub.