mastra-ai/mastra · error
OrchestrationWorker not initialized
Error message
OrchestrationWorker not initialized
What it means
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.
Source
Thrown at packages/core/src/worker/workers/orchestration-worker.ts:109
if (!this.#running) return;
try {
if (this.#transport) {
await this.#transport.stop();
this.#transport = undefined;
}
} finally {
this.#running = false;
}
}
get isRunning(): boolean {
return this.#running;
}
async #processEvent(event: Event, ack?: () => Promise<void>, nack?: () => Promise<void>): Promise<void> {
if (!this.#processor) {
throw new Error('OrchestrationWorker not initialized');
}
// The local processor is used (rather than mastra.handleWorkflowEvent)
// because it carries the standalone-worker step-execution strategy
// (HttpRemoteStrategy when MASTRA_STEP_EXECUTION_URL is set), which the
// shared in-process handler doesn't have.
const result = await this.#processor.handle(event);
if (result.ok) {
try {
await ack?.();
} catch (e) {
this.deps?.logger?.error('OrchestrationWorker: error acking event', { error: e });
}
return;
}
this.deps?.logger?.error('OrchestrationWorker: error processing event', {
type: event.type,View on GitHub (pinned to 75dd419e61)
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)
Example fix
// before
try { await w.init(deps); } catch (e) { /* swallowed */ }
await w.start(); // events arrive with no processor
// after
await w.init(deps); // let failures surface
await w.start(); Defensive patterns
Strategy: try-catch
Validate before calling
await worker.init(deps); // must fully succeed
if (!worker.deps) throw new Error('init incomplete'); Try / catch
try {
await w.start();
} catch (e) {
if (e.message === 'OrchestrationWorker not initialized') {
logger.error('Event arrived before init completed — restart worker after full init');
await w.stop?.();
} else throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- IssueReconcileWorker: call init() before start()
- Database was ${db.status === 'deleted' ? 'deleted' : 'schedu
- AgentScheduleWorker: call init() before start()
- InProcessStrategy requires Mastra instance. Call __registerM
- BackgroundTaskWorker: call init() before start()
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/a95e2822bb900981.
Report an issue: GitHub.