{"record":{"id":"afb4d32211ec57fe","repo":"windmill-labs/windmill","slug":"timed-out-waiting-for-job-id-to-complete","errorCode":null,"errorMessage":"Timed out waiting for job ${id} to complete","messagePattern":"Timed out waiting for job (.+?) to complete","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/script/script.ts","lineNumber":1491,"sourceCode":"      if (completedJob.success === false) {\n        process.exitCode = 1;\n      }\n\n      const result = completedJob.result ?? {};\n      if (opts.silent) {\n        console.log(JSON.stringify(result));\n      } else {\n        log.info(JSON.stringify(result, null, 2));\n      }\n\n      break;\n    } catch {\n      retries++;\n      await new Promise((resolve) => setTimeout(resolve, 100));\n    }\n  }\n  if (retries >= MAX_RETRIES) {\n    throw new Error(`Timed out waiting for job ${id} to complete`);\n  }\n}\n\nexport async function track_job(workspace: string, id: string) {\n  try {\n    const result = await wmill.getCompletedJob({ workspace, id });\n\n    log.info(result.logs);\n    log.info(\"\\n\");\n    log.info(colors.bold.underline.green(\"Job Completed\"));\n    log.info(\"\\n\");\n    return;\n  } catch {\n    /* ignore */\n  }\n\n  log.info(colors.yellow(\"Waiting for Job \" + id + \" to start...\"));\n","sourceCodeStart":1473,"sourceCodeEnd":1509,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/commands/script/script.ts#L1473-L1509","documentation":"The CLI polls `getCompletedJob` up to MAX_RETRIES times (with 100ms backoff) when waiting for a script run to finish. If the job never reaches a completed state within that window, it gives up with this timeout error. The job may still be running server-side.","triggerScenarios":"`wmill script run --wait` (or track) against a long-running script, or a job stuck in queue because all workers are busy/down; polls exhaust MAX_RETRIES at ~100ms intervals.","commonSituations":"A script that takes longer than the CLI's fixed polling budget (heavy data processing, LLM calls); no dedicated worker online so the job sits queued; worker crashed mid-run leaving the job in a non-terminal state.","solutions":["Re-run with the job ID visible via `wmill job show <id>` or the UI to check the job's real status.","Check that workers are running and not saturated (queue depth in the UI).","Split a long-running script into smaller steps or increase its timeout/limits.","Retry the run; if jobs repeatedly hang, inspect worker logs for crashes."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const job = await wmill.getJob({ workspace, id });\nconsole.log('Job currently:', job.running ? 'running' : job.type); // sanity-check before waiting","typeGuard":null,"tryCatchPattern":"try {\n  const result = await wmill.script.run(path, { wait: true });\n} catch (e) {\n  if (String(e.message).startsWith('Timed out waiting for job')) {\n    const id = e.message.match(/job (\\S+) /)?.[1];\n    console.error(`CLI gave up; job ${id} may still be running — check 'wmill job show ${id}'.`);\n  }\n  throw e;\n}","preventionTips":["Check worker availability/queue depth before long waits.","Keep scripts under the CLI's polling budget or use async run + manual tracking.","Monitor job state via the UI or `wmill job show` for long jobs."],"tags":["cli","timeout","polling","async-job"],"backgroundTag":"job-timeout-waiting-for-completion","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}