{"record":{"id":"7ca3b95914f20280","repo":"mastra-ai/mastra","slug":"workflow-wait-for-event-removed","errorCode":"WORKFLOW_WAIT_FOR_EVENT_REMOVED","errorMessage":"waitForEvent has been removed. Please use suspend & resume flow instead. See https://mastra.ai/en/docs/workflows/suspend-and-resume for more details.","messagePattern":"waitForEvent has been removed\\. Please use suspend & resume flow instead\\. See https://mastra\\.ai/en/docs/workflows/suspend-and-resume for more details\\.","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/workflows/workflow.ts","lineNumber":2060,"sourceCode":"      TState,\n      TInput,\n      TOutput,\n      TPrevSchema,\n      TRequestContext\n    >;\n  }\n\n  /**\n   * @deprecated waitForEvent has been removed. Please use suspend/resume instead.\n   */\n  waitForEvent<TStepState, TStepInputSchema extends TPrevSchema, TStepId extends string, TSchemaOut>(\n    _event: string,\n    _step: Step<TStepId, SubsetOf<TStepState, TState>, TStepInputSchema, TSchemaOut, any, any, TEngineType>,\n    _opts?: {\n      timeout?: number;\n    },\n  ) {\n    throw new MastraError({\n      id: 'WORKFLOW_WAIT_FOR_EVENT_REMOVED',\n      domain: ErrorDomain.MASTRA_WORKFLOW,\n      category: ErrorCategory.USER,\n      text: 'waitForEvent has been removed. Please use suspend & resume flow instead. See https://mastra.ai/en/docs/workflows/suspend-and-resume for more details.',\n    });\n  }\n\n  map(\n    mappingConfig:\n      | {\n          [k: string]:\n            | {\n                step:\n                  | Step<string, any, any, any, any, any, TEngineType, any>\n                  | Step<string, any, any, any, any, any, TEngineType, any>[];\n                path: string;\n              }\n            | { value: any; schema: PublicSchema<any> }","sourceCodeStart":2042,"sourceCodeEnd":2078,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/workflows/workflow.ts#L2042-L2078","documentation":"`Workflow.waitForEvent()` is no longer implemented: calling it throws immediately. The event-waiting API was removed from Mastra workflows in favor of the suspend & resume pattern, which persists the run and resumes it when an external event arrives.","triggerScenarios":"Any call to `workflow.waitForEvent(eventName, step, { timeout })` on a workflow built with the current engine; typically code migrated from an older Mastra version that used waitForEvent for human-in-the-loop or external approval flows.","commonSituations":"Upgrading Mastra and old workflow code still calling waitForEvent; following outdated tutorials/snippets; porting Temporal-style signal/wait patterns into Mastra.","solutions":["Replace waitForEvent with `await step.suspend()` and a later `run.resume({ resumeData })` triggered by your external event handler.","Follow the suspend-and-resume docs: https://mastra.ai/en/docs/workflows/suspend-and-resume","Model the 'event' as resumeData payload passed to the suspended step.","Remove any `_opts.timeout` usage and implement timeouts yourself (e.g. a timer step that resumes with an 'expired' payload)."],"exampleFix":"// before\nworkflow.waitForEvent('approval', approvalStep, { timeout: 3600 });\n// after\napprovalStep.suspend();\n// in your event handler:\nawait run.resume({ stepId: 'approvalStep', resumeData: { approved: true } });","handlingStrategy":"type-guard","validationCode":"declare module './workflow' { interface Workflow { waitForEvent?: never } }\n// or a runtime check during migration:\nif ('waitForEvent' in workflow && typeof workflow.waitForEvent === 'function') {\n  throw new Error('migrate waitForEvent to suspend/resume');\n}","typeGuard":null,"tryCatchPattern":"try {\n  // legacy call path\n  (workflow as any).waitForEvent(name, step, opts);\n} catch (e) {\n  if (String(e?.message).includes('waitForEvent has been removed')) {\n    // fall back to suspend/resume flow\n  } else throw e;\n}","preventionTips":["Grep for waitForEvent during Mastra upgrades and migrate to suspend/resume.","Use TypeScript overload types that no longer expose waitForEvent.","Follow the official suspend-and-resume docs for human-in-the-loop patterns."],"tags":["workflow","removed-api","migration","suspend-resume"],"backgroundTag":"api-removed-breaking-change","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}