{"record":{"id":"a434332173cc5c16","repo":"santifer/career-ops","slug":"apify-actor-actorid-finished-with-status-run","errorCode":null,"errorMessage":"Apify actor ${actorId} finished with status ${run.status}${reason}","messagePattern":"Apify actor (.+?) finished with status (.+?)(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/apify/_apify.mjs","lineNumber":199,"sourceCode":"  if (!Array.isArray(items)) {\n    throw new Error(`Apify run ${runId} returned non-array dataset payload`);\n  }\n  return items;\n}\n\nexport async function runActor(actorId, input, { timeoutMs = DEFAULT_RUN_TIMEOUT_MS, token = process.env.APIFY_TOKEN } = {}) {\n  if (!token) throw new Error('APIFY_TOKEN not set');\n  if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {\n    throw new Error(`apify: invalid timeoutMs ${JSON.stringify(timeoutMs)} (must be a positive finite number of milliseconds)`);\n  }\n  // Single deadline shared across startRun → waitForRun → fetchDatasetItems so\n  // the caller's timeoutMs is the end-to-end ceiling, not just the wait loop.\n  const deadline = Date.now() + timeoutMs;\n  const runId = await startRun(actorId, input, token, deadline);\n  const run = await waitForRun(runId, token, deadline, timeoutMs);\n  if (run.status !== 'SUCCEEDED') {\n    const reason = run.statusMessage ? `: ${run.statusMessage}` : '';\n    throw new Error(`Apify actor ${actorId} finished with status ${run.status}${reason}`);\n  }\n  return await fetchDatasetItems(runId, token, deadline);\n}\n","sourceCodeStart":181,"sourceCodeEnd":203,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/plugins/apify/_apify.mjs#L181-L203","documentation":"After waiting for an Apify actor run, runActor requires the run's final status to be exactly 'SUCCEEDED'. Any other terminal status (FAILED, ABORTED, TIMED-OUT, etc.) throws this error, appending the run's statusMessage when present.","triggerScenarios":"The actor run ends with status FAILED (actor crashed), ABORTED (manually or by timeout), TIMED-OUT, or any non-SUCCEEDED status returned by waitForRun.","commonSituations":"Actor input is invalid so the actor fails at startup; actor hits a memory limit and crashes; Apify platform aborts the run because it exceeded the run timeout; actor code itself throws; account out of Apify credit so run is aborted.","solutions":["Read the appended statusMessage and the run details in the Apify console to see the failure reason.","Fix the actor input (validate required fields the actor expects).","Increase timeoutMs / actor run timeout if the run is being killed early.","Retry the run — transient platform or memory issues often resolve.","Check Apify account usage/billing if runs are aborted for credit exhaustion."],"exampleFix":"// before\nconst items = await runActor('user/actor', { bad: true }, { timeoutMs: 60000 });\n// after\ntry {\n  const items = await runActor('user/actor', validatedInput, { timeoutMs: 120000 });\n} catch (e) {\n  if (e.message.includes('finished with status')) console.error('Actor failed:', e.message);\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const items = await runActor(actorId, input, { timeoutMs: 120000 });\n} catch (e) {\n  const m = String(e.message);\n  if (m.includes('finished with status')) {\n    const status = m.match(/status (\\S+)/)?.[1];\n    if (status === 'TIMED-OUT') return retryWithLongerTimeout();\n    if (status === 'ABORTED' || status === 'FAILED') console.error('Actor failed:', m);\n  }\n  throw e;\n}","preventionTips":["Validate actor input against the actor's input schema before running.","Set timeoutMs generously relative to expected actor runtime.","Monitor Apify account usage to avoid credit-exhaustion aborts.","Retry transient statuses (ABORTED/TIMED-OUT) with backoff."],"tags":["apify","actor","run-failed","api"],"backgroundTag":"api-error-response","analyzedSha":"aac998c7ed7248ea853b720ceeb1fdbeb322fc5d","analyzedAt":"2026-09-16T06:35:29.214Z","contentChangedAt":"2026-09-16T06:35:29.214Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}