Skip to content

Commit

Permalink
fix(): add warning when listener added on request-scoped class
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Dec 11, 2020
1 parent c6369e7 commit b21596d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off'
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/ban-types': 'off'
},
};
9 changes: 8 additions & 1 deletion lib/bull.explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class BullExplorer implements OnModuleInit {
const metadata = this.metadataAccessor.getListenerMetadata(
instance[key],
);
this.handleListener(instance, key, bullQueue, metadata);
this.handleListener(instance, key, wrapper, bullQueue, metadata);
}
},
);
Expand Down Expand Up @@ -124,9 +124,16 @@ export class BullExplorer implements OnModuleInit {
handleListener(
instance: object,
key: string,
wrapper: InstanceWrapper,
queue: Queue,
options: BullQueueEventOptions,
) {
if (!wrapper.isDependencyTreeStatic()) {
this.logger.warn(
`Warning! "${wrapper.name}" class is request-scoped and it defines an event listener ("${wrapper.name}#${key}"). Since event listeners cannot be registered on scoped providers, this handler will be ignored.`,
);
return;
}
if (options.name || options.id) {
queue.on(
options.eventName,
Expand Down

0 comments on commit b21596d

Please sign in to comment.