mastra-ai/mastra · error · Error
No Pubsub adapter configured on the Mastra instance
Error message
No Pubsub adapter configured on the Mastra instance
What it means
The evented workflow execution engine's execute() method requires a Pub/Sub adapter to publish step events and subscribe for results. If mastra.pubsub is undefined, it throws immediately before doing any work, because the evented path cannot function without it.
Solutions
- Configure a pubsub adapter on Mastra: new Mastra({ pubsub: myPubsubAdapter, ... }).
- Verify you are executing against the same configured Mastra instance (this.mastra is set).
- If you don't need evented execution, use the standard (non-evented) workflow run path instead.
Example fix
// before
const mastra = new Mastra({ agents: {...} });
await eventedEngine.execute(...); // throws
// after
const mastra = new Mastra({ agents: {...}, pubsub: new InMemoryPubSubAdapter() }); Defensive patterns
Strategy: validation
Validate before calling
if (!mastra?.pubsub) {
throw new Error('Evented workflow execution requires a pubsub adapter; configure Mastra({ pubsub: ... })');
} Type guard
function supportsEventedExecution(mastra: Mastra | undefined): mastra is Mastra & { pubsub: NonNullable<Mastra['pubsub']> } {
return !!mastra?.pubsub;
} Try / catch
try { await eventedEngine.execute(...); } catch (e) { if (e.message === 'No Pubsub adapter configured on the Mastra instance') { return runStandardEngine(input); } throw e; } Prevention
- Add a pubsub adapter to Mastra config before enabling evented workflows.
- Use a single shared Mastra factory so all engine paths see the same configuration.
- Feature-flag evented execution and gate on pubsub presence.
- Write an integration test that asserts evented execute() boots cleanly.
When it happens
Trigger: Calling the evented execution engine's execute() (evented workflow run) on a Mastra instance that was constructed without a pubsub adapter, or where this.mastra is undefined.
Common situations: Switching a workflow to the evented engine without adding MastraOptions.pubsub; using a Mastra instance created in a different module than the one configured; forgetting to migrate configuration when opting into evented workflows.
Related errors
- Mastra instance with pubsub is required for workflow…
- Agent ' ' not found for workflow step ' '. Register the…
- crossProcessPubSub requires a pubsub instance
- list-available-workflows requires a Mastra context.
- list-workflows requires a Mastra context.
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/17511c4f0d921d81.
Report an issue: GitHub.
Appendix: source
Thrown at packages/core/src/workflows/evented/execution-engine.ts:93
forEachIndex?: number;
};
pubsub?: PubSub; // Not used - evented engine uses this.mastra.pubsub directly
requestContext: RequestContext;
retryConfig?: {
attempts?: number;
delay?: number;
};
abortController: AbortController;
format?: 'legacy' | 'vnext' | undefined;
outputOptions?: {
includeState?: boolean;
includeResumeLabels?: boolean;
};
perStep?: boolean;
}): Promise<TOutput> {
const pubsub = this.mastra?.pubsub;
if (!pubsub) {
throw new Error('No Pubsub adapter configured on the Mastra instance');
}
// Set up promise that will resolve when workflow finishes
// CRITICAL: Must subscribe BEFORE publishing events to avoid race condition
let resolveResult!: (data: any) => void;
let rejectResult!: (error: any) => void;
const resultPromise = new Promise<any>((resolve, reject) => {
resolveResult = resolve;
rejectResult = reject;
});
const finishCb = async (event: Event, ack?: () => Promise<void>) => {
if (event.runId !== params.runId) {
await ack?.();
return;
}
if (['workflow.end', 'workflow.fail', 'workflow.suspend'].includes(event.type)) {View on GitHub (pinned to 75dd419e61)