Skip to content

Commit

Permalink
Merge pull request #1009 from zackdotcomputer/master
Browse files Browse the repository at this point in the history
fix(@nestjs/event-emitter): Circumvent crash in reflect-metadata
  • Loading branch information
kamilmysliwiec committed Nov 8, 2023
2 parents 1e967dc + 36d68f1 commit 2ec39f8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/events-metadata.accessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ export class EventsMetadataAccessor {
getEventHandlerMetadata(
target: Type<unknown>,
): 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;
Expand Down

0 comments on commit 2ec39f8

Please sign in to comment.