{"record":{"id":"ad1f042d9692dc86","repo":"jackwener/OpenCLI","slug":"midjourney-reference-upload","errorCode":null,"errorMessage":"Midjourney reference upload","messagePattern":"Midjourney reference upload","errorType":"exception","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"clis/midjourney/utils.js","lineNumber":1137,"sourceCode":"  let capturedSources = [];\n  if (captureReady) {\n    try {\n      await page.waitForCapture(10);\n      capturedSources = uploadedStorageUrlsFromCaptures(await page.getInterceptedRequests());\n    } catch {}\n  }\n\n  let newSources = [];\n  for (let attempt = 0; attempt < 30; attempt += 1) {\n    await page.wait(1);\n    const currentSources = await visibleImageSources(page);\n    const capturedVisible = capturedSources.filter((url) => currentSources.includes(url));\n    if (capturedVisible.length >= localPaths.length) return capturedVisible.slice(0, localPaths.length);\n    newSources = currentSources.filter((url) => !before.has(url));\n    if (newSources.length >= localPaths.length) break;\n  }\n  if (newSources.length < localPaths.length) {\n    throw new TimeoutError('Midjourney reference upload', 30, `Expected ${localPaths.length} uploaded image(s), saw ${newSources.length}.`);\n  }\n\n  return newSources.slice(0, localPaths.length);\n}\n\nasync function openEndFramePicker(page) {\n  const marked = unwrapEvaluateResult(await page.evaluate(() => {\n    document.querySelectorAll('[data-opencli-end-frame-picker]').forEach((node) => {\n      node.removeAttribute('data-opencli-end-frame-picker');\n    });\n    const label = [...document.querySelectorAll('div')]\n      .find((node) => node.children.length === 0 && node.textContent?.trim() === 'End Frame');\n    let target = label;\n    for (let depth = 0; depth < 7 && target; depth += 1, target = target.parentElement) {\n      if (String(target.className).includes('cursor-pointer')) {\n        target.setAttribute('data-opencli-end-frame-picker', '1');\n        return true;\n      }","sourceCodeStart":1119,"sourceCodeEnd":1155,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/midjourney/utils.js#L1119-L1155","documentation":"TimeoutError thrown when fewer images than the number of local paths uploaded were detected within 30 seconds. The function compares visible image sources before and after upload and counts brand-new URLs as uploaded images.","triggerScenarios":"uploadReferenceLibrary waits 30s polling visibleImageSources; newSources.length < localPaths.length at the deadline (e.g. 2 files given but only 1 new image URL appeared).","commonSituations":"Midjourney deduplicates identical images already uploaded; uploads partially failed; slow network/CPU caused thumbnails not to render in 30s; the page was mid-navigation.","solutions":["Retry the upload; transient slowness is the most common cause.","Check for duplicate local files — Midjourney may reuse an existing image URL so it won't count as 'new'.","Increase the 30s timeout or poll interval for slow connections.","Verify each file uploads individually and confirm counts before batch uploads."],"exampleFix":"// before\nthrow new TimeoutError('Midjourney reference upload', 30, `Expected ${localPaths.length} uploaded image(s), saw ${newSources.length}.`);\n// after\nif (newSources.length < localPaths.length) {\n  await retryUpload(page, localPaths);\n  throw new TimeoutError('Midjourney reference upload', 30, `Expected ${localPaths.length} uploaded image(s), saw ${newSources.length}.`);\n}","handlingStrategy":"retry","validationCode":"if (!localPaths.length) return [];\nconst unique = [...new Set(localPaths.map(p => require('fs').realpathSync(p)))];\nif (unique.length !== localPaths.length) console.warn('duplicate images may not count as new uploads');","typeGuard":null,"tryCatchPattern":"try {\n  await uploadReferenceLibrary(page, paths);\n} catch (err) {\n  if (err.name === 'TimeoutError') {\n    await page.wait(5);\n    await uploadReferenceLibrary(page, paths);\n  } else throw err;\n}","preventionTips":["Avoid uploading duplicate images in one batch","Allow longer timeouts on slow connections","Upload files one at a time to isolate failures","Confirm page stability before uploading"],"tags":["midjourney","timeout","file-upload","network"],"backgroundTag":"upload-timeout","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}