{"record":{"id":"a95e2822bb900981","repo":"mastra-ai/mastra","slug":"orchestrationworker-not-initialized","errorCode":null,"errorMessage":"OrchestrationWorker not initialized","messagePattern":"OrchestrationWorker not initialized","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/worker/workers/orchestration-worker.ts","lineNumber":109,"sourceCode":"    if (!this.#running) return;\n\n    try {\n      if (this.#transport) {\n        await this.#transport.stop();\n        this.#transport = undefined;\n      }\n    } finally {\n      this.#running = false;\n    }\n  }\n\n  get isRunning(): boolean {\n    return this.#running;\n  }\n\n  async #processEvent(event: Event, ack?: () => Promise<void>, nack?: () => Promise<void>): Promise<void> {\n    if (!this.#processor) {\n      throw new Error('OrchestrationWorker not initialized');\n    }\n\n    // The local processor is used (rather than mastra.handleWorkflowEvent)\n    // because it carries the standalone-worker step-execution strategy\n    // (HttpRemoteStrategy when MASTRA_STEP_EXECUTION_URL is set), which the\n    // shared in-process handler doesn't have.\n    const result = await this.#processor.handle(event);\n    if (result.ok) {\n      try {\n        await ack?.();\n      } catch (e) {\n        this.deps?.logger?.error('OrchestrationWorker: error acking event', { error: e });\n      }\n      return;\n    }\n\n    this.deps?.logger?.error('OrchestrationWorker: error processing event', {\n      type: event.type,","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/worker/workers/orchestration-worker.ts#L91-L127","documentation":"start() wires #processor from init()-provided deps before the PullTransport routes events into #processEvent. If an event arrives while #processor is unset, the worker has no step-execution strategy to handle it and throws this internal-state error, protecting against processing events with an uninitialized pipeline.","triggerScenarios":"The transport's route callback fires before init() assigned the processor — e.g. start() called before/without init on a transport that's already running, or init() failing partway after the transport started delivering events.","commonSituations":"Reusing a running transport across a stop/start cycle without re-init; calling start() without init() in a code path that swallows the earlier 'call init() before start()' error; async races where an event is delivered during startup.","solutions":["Always await init(deps) before start() and let its error stop startup instead of catching and continuing","Recreate (not reuse) the worker/transport after a failed init","Check that init() isn't rejecting after the transport already started; fix the underlying init error (e.g. missing mastra or push-only pubsub)"],"exampleFix":"// before\ntry { await w.init(deps); } catch (e) { /* swallowed */ }\nawait w.start(); // events arrive with no processor\n// after\nawait w.init(deps); // let failures surface\nawait w.start();","handlingStrategy":"try-catch","validationCode":"await worker.init(deps); // must fully succeed\nif (!worker.deps) throw new Error('init incomplete');","typeGuard":null,"tryCatchPattern":"try {\n  await w.start();\n} catch (e) {\n  if (e.message === 'OrchestrationWorker not initialized') {\n    logger.error('Event arrived before init completed — restart worker after full init');\n    await w.stop?.();\n  } else throw e;\n}","preventionTips":["Let init() failures abort startup rather than continuing to start()","Recreate workers after failed init instead of reusing partially-built state","Sequence init→start strictly; avoid racing transports that deliver immediately"],"tags":["worker","lifecycle","race-condition"],"backgroundTag":"worker-not-initialized","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}