{"record":{"id":"eebabc3e3fd3b9a0","repo":"medusajs/medusa","slug":"no-emitevents-method-found-on-target-constructo","errorCode":null,"errorMessage":"No emitEvents_ method found on ${target.constructor.name}. No events emitted. To be able to use the @EmitEvents() you need to have the emitEvents_ method implemented in the class.","messagePattern":"No emitEvents_ method found on (.+?)\\. No events emitted\\. To be able to use the @EmitEvents\\(\\) you need to have the emitEvents_ method implemented in the class\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/core/utils/src/modules-sdk/decorators/emit-events.ts","lineNumber":32,"sourceCode":"  return function (\n    target: any,\n    propertyKey: string | symbol,\n    descriptor: any\n  ): void {\n    InjectIntoContext({\n      messageAggregator: () => new MessageAggregator(),\n    })(target, propertyKey, descriptor)\n\n    const original = descriptor.value\n\n    descriptor.value = async function (...args: any[]) {\n      const result = await original.apply(this, args)\n\n      if (!target.emitEvents_) {\n        const logger = Object.keys(this.__container__ ?? {}).includes(\"logger\")\n          ? this.__container__.logger\n          : console\n        logger.warn(\n          `No emitEvents_ method found on ${target.constructor.name}. No events emitted. To be able to use the @EmitEvents() you need to have the emitEvents_ method implemented in the class.`\n        )\n      }\n\n      const argIndex = target.MedusaContextIndex_[propertyKey]\n      const aggregator = args[argIndex].messageAggregator as MessageAggregator\n\n      if (aggregator.count() > 0) {\n        await target.emitEvents_.apply(this, [aggregator.getMessages(options)])\n        aggregator.clearMessages()\n      }\n\n      return result\n    }\n  }\n}\n","sourceCodeStart":14,"sourceCodeEnd":49,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/core/utils/src/modules-sdk/decorators/emit-events.ts#L14-L49","documentation":"The @EmitEvents() decorator runs the decorated method, then forwards the aggregated messages collected via the MedusaContext messageAggregator to the class's emitEvents_ method. If the service class has no emitEvents_ method, the collected events are simply dropped with this warning. The method is normally provided by extending MedusaService; hand-written services that add the decorator without the base class lose events.","triggerScenarios":"Adding @EmitEvents() to a method of a class that does not extend MedusaService (or otherwise does not define an async emitEvents_(context) method). Medusa module services like ApiKeyModuleService/CartModuleService etc. get it from the base class, so this only fires for custom or mis-wired classes.","commonSituations":"Building a custom service that mimics Medusa module services and copying the decorator; refactoring a service to no longer extend MedusaService while keeping decorators; mocking services in tests (FakeService) that apply the decorator without the base implementation.","solutions":["Make the class extend MedusaService<...>(models), which implements emitEvents_","Or implement emitEvents_ manually: protected async emitEvents_(context: Context) { ... flush context.messageAggregator messages ... }","Remove @EmitEvents() from methods of classes that should not emit domain events"],"exampleFix":"// before\nexport class MyService { // no base class\n  @EmitEvents()\n  async createThing(...) {}\n}\n\n// after\nexport class MyService extends MedusaService<{ Thing: { dto: ThingDTO } }>({ Thing }) {\n  @EmitEvents()\n  async createThing(...) {}\n}","handlingStrategy":"type-guard","validationCode":"if (typeof (service as any).emitEvents_ !== \"function\") {\n  console.warn(\"@EmitEvents used on class without emitEvents_\")\n}","typeGuard":"const canEmitEvents = (s: object): boolean =>\n  typeof (s as { emitEvents_?: unknown }).emitEvents_ === \"function\"","tryCatchPattern":null,"preventionTips":["Extend MedusaService for any class using @EmitEvents","Don't copy decorators onto hand-written services without emitEvents_","In tests, mock emitEvents_ on fake services"],"tags":["decorators","event-emission","modules-sdk","medusa-service"],"backgroundTag":"missing-abstract-method-implementation","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}