diff --git a/lib/events-metadata.accessor.ts b/lib/events-metadata.accessor.ts index 8275e59b..3d1b3f4b 100644 --- a/lib/events-metadata.accessor.ts +++ b/lib/events-metadata.accessor.ts @@ -10,6 +10,15 @@ export class EventsMetadataAccessor { getEventHandlerMetadata( target: Type, ): OnEventMetadata[] | undefined { + // Circumvent a crash that comes from reflect-metadata if it is + // given a non-object non-function target to reflect upon. + if ( + !target || + (typeof target !== 'function' && typeof target !== 'object') + ) { + return undefined; + } + const metadata = this.reflector.get(EVENT_LISTENER_METADATA, target); if (!metadata) { return undefined;