{"record":{"id":"a4fab8070c1c33f0","repo":"jackwener/OpenCLI","slug":"midjourney-job-submission-a4fab8","errorCode":null,"errorMessage":"Midjourney job submission","messagePattern":"Midjourney job submission","errorType":"exception","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"clis/midjourney/utils.js","lineNumber":467,"sourceCode":"        && promptCore(candidate) === expectedCore\n        && promptKeySignature(candidate) === expectedSignature\n      );\n    });\n    if (matching.length === expectedCount) {\n      return [...matching]\n        .sort((left, right) => Date.parse(left.enqueue_time) - Date.parse(right.enqueue_time))\n        .map((row) => String(row.id).toLowerCase());\n    }\n    if (matching.length > expectedCount) ambiguousIds = matching.map((row) => String(row.id).toLowerCase());\n    if (!(await waitForNextPoll(page, deadline, 1.5))) break;\n  } while (true);\n  if (ambiguousIds.length > expectedCount) {\n    throw new CommandExecutionError(\n      `Midjourney submission is ambiguous; ${ambiguousIds.length} new jobs matched the prompt`,\n      ambiguousIds.map((id) => jobUrl(id)).join(', '),\n    );\n  }\n  throw new TimeoutError(\n    'Midjourney job submission',\n    timeoutSeconds,\n    `Expected ${expectedCount} uniquely matched job(s) after submission.`,\n  );\n}\n\nexport async function waitForDerivedJob(page, userId, parentJobId, baselineIds, timeoutSeconds, submittedAtMs) {\n  const deadline = Date.now() + timeoutSeconds * 1000;\n  let candidates = [];\n  let consecutivePollFailures = 0;\n  do {\n    let recent;\n    try {\n      recent = await fetchHistory(page, userId, 50);\n      consecutivePollFailures = 0;\n    } catch (error) {\n      if (error instanceof AuthRequiredError) throw error;\n      consecutivePollFailures += 1;","sourceCodeStart":449,"sourceCodeEnd":485,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/midjourney/utils.js#L449-L485","documentation":"This is the TimeoutError raised when the submit-and-wait loop exhausts its deadline without finding the expected number of uniquely matched new jobs (and no ambiguity was detected). The operation name 'Midjourney job submission' identifies the phase; the detail explains how many jobs were expected.","triggerScenarios":"The polling loop's deadline (timeoutSeconds) expires because the submitted job never appeared in job-status results: submission silently failed, the prompt produced no job, the job took longer than the timeout to register, or waitForNextPoll kept breaking early.","commonSituations":"Too-low timeoutSeconds for slow generations or congested queues; Midjourney not registering the job due to an unobserved UI failure; subscription exhausted (no fast hours) causing queued jobs that exceed the window.","solutions":["Increase timeoutSeconds and retry the submission.","Verify on midjourney.com whether the job actually was created; if yes, poll it by ID with waitForCompletedJob instead of re-submitting.","Check Midjourney queue/subscription state — exhausted fast hours can delay job registration past the timeout.","Avoid resubmitting blindly, or you may create duplicate jobs (see the ambiguity error)."],"exampleFix":"// before\nawait submitAndAwait(page, prompt, { timeoutSeconds: 30 });\n// after\nawait submitAndAwait(page, prompt, { timeoutSeconds: 120 }); // allow for slow queue registration","handlingStrategy":"retry","validationCode":"// pre-flight: confirm the subscription/queue can accept jobs before submitting\nconst jobs = await fetchJobStatuses(page, recentJobIds).catch(() => []);\nconst queued = jobs.filter((j) => String(j.current_status || j.status || '').toLowerCase() === 'waiting');\nif (queued.length > 5) console.warn('Queue is congested; use a longer timeoutSeconds.');","typeGuard":null,"tryCatchPattern":"async function submitWithTimeoutRetry(page, prompt, timeoutSeconds) {\n  try {\n    return await submitAndAwait(page, prompt, { timeoutSeconds });\n  } catch (e) {\n    if (String(e.message).includes('Midjourney job submission')) {\n      // check web UI for the job before resubmitting to avoid duplicates\n      return submitAndAwait(page, prompt, { timeoutSeconds: timeoutSeconds * 2 });\n    }\n    throw e;\n  }\n}","preventionTips":["Set timeoutSeconds generously (60-180s) for congested queues","Check for the created job on midjourney.com before any retry to prevent duplicates","Ensure fast hours/subscription are available for timely job registration","Log submission timestamps so you can correlate timeouts with site-side state"],"tags":["midjourney","timeout","polling"],"backgroundTag":"poll-timeout","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}