{"record":{"id":"ce2157182c6f3249","repo":"apache/beam","slug":"job-finished-in-state-jobstate-enum-finalstate","errorCode":null,"errorMessage":"Job finished in state ${JobState_Enum[finalState]}","messagePattern":"Job finished in state (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"sdks/typescript/src/apache_beam/runners/runner.ts","lineNumber":110,"sourceCode":"export abstract class Runner {\n  /**\n   * Runs the transform.\n   *\n   * Resolves to an instance of PipelineResult when the pipeline completes.\n   * Use runAsync() to execute the pipeline in the background.\n   *\n   * @param pipeline\n   * @returns A PipelineResult\n   */\n  async run(\n    pipeline: (root: Root) => PValue<any> | Promise<PValue<any>>,\n    options?: PipelineOptions,\n  ): Promise<PipelineResult> {\n    const pipelineResult = await this.runAsync(pipeline, options);\n    const finalState = await pipelineResult.waitUntilFinish();\n    if (finalState != JobState_Enum.DONE) {\n      // TODO: Grab the last/most severe error message?\n      throw new Error(\"Job finished in state \" + JobState_Enum[finalState]);\n    }\n    return pipelineResult;\n  }\n\n  /**\n   * runAsync() is the asynchronous version of run(), does not wait until\n   * pipeline finishes. Use the returned PipelineResult to query job\n   * status.\n   */\n  async runAsync(\n    pipeline: (root: Root) => PValue<any> | Promise<PValue<any>>,\n    options?: PipelineOptions,\n  ): Promise<PipelineResult> {\n    const p = new Pipeline();\n    await pipeline(new Root(p));\n    return this.runPipeline(p.getProto());\n  }\n","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/typescript/src/apache_beam/runners/runner.ts#L92-L128","documentation":"Runner.run() awaits runAsync() then waitUntilFinish(); if the job terminates in any state other than DONE (e.g. FAILED, CANCELLED, UNKNOWN), it throws 'Job finished in state <STATE>'. The message names the JobState_Enum numeric value's key so developers can see which terminal state the job reached. It indicates the pipeline ran but did not complete successfully.","triggerScenarios":"Calling runner.run(pipeline, options) when the submitted job ends in a non-DONE state — e.g. the job fails on the remote service, is cancelled, or times out.","commonSituations":"Worker crashes on a Dataflow/Flink job, bad pipeline logic causing runtime failure, job cancelled by a user or platform policy, quota or infrastructure failures.","solutions":["Inspect job logs on the runner service to find the root cause of the non-DONE state.","Catch the error and check the returned PipelineResult/job state for retryable outcomes before re-submitting.","Fix the pipeline error (bad input, OOM, missing resources) that caused the job to fail."],"exampleFix":"// before\nawait runner.run(pipeline, options);\n// after\ntry {\n  await runner.run(pipeline, options);\n} catch (e) {\n  console.error(\"Pipeline did not finish in DONE state:\", e.message);\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"// Validate pipeline options (project, region, tempLocation) before submitting\nclass MyFn extends DoFn {}\nawait runner.runAsync(pipeline, options); // prefer runAsync + explicit waitUntilFinish for state control","typeGuard":"function isDone(state: JobState_Enum) { return state === JobState_Enum.DONE; }","tryCatchPattern":"try {\n  await runner.run(pipeline, options);\n} catch (e) {\n  if (e.message.startsWith(\"Job finished in state\")) {\n    console.error(\"Pipeline job failed:\", e.message);\n    // inspect service logs before retrying\n  } else throw e;\n}","preventionTips":["Check job logs on the runner service after any non-DONE state","Validate options (project, region, quotas) before submission","Use runAsync + waitUntilFinish for finer state handling","Implement retry with backoff for transient infrastructure failures"],"tags":["job-state","runner","pipeline-failure"],"backgroundTag":"invalid-state-transition","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}