You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[ ] Regression
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
The ScheduleExplorer will throw an unhandled promise rejection upon module initialization if the discovery service returned any providers that have a null prototype.
The provider will make it past the instance check and the error will ultimately be thrown inside the getAllFilteredMethodNames method when attempting to access properties of the null prototype:
(node:81446) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object
at Function.getOwnPropertyNames (<anonymous>)
at MetadataScanner.getAllFilteredMethodNames (/source/project/node_modules/@nestjs/core/metadata-scanner.js:24:45)
at getAllFilteredMethodNames.next (<anonymous>)
at new Set (<anonymous>)
at MetadataScanner.scanFromPrototype (/source/project/node_modules/@nestjs/core/metadata-scanner.js:9:29)
at /source/project/node_modules/@nestjs/schedule/dist/schedule.explorer.js:36:34
at Array.forEach (<anonymous>)
at ScheduleExplorer.explore (/source/project/node_modules/@nestjs/schedule/dist/schedule.explorer.js:30:19)
at ScheduleExplorer.onModuleInit (/source/project/node_modules/@nestjs/schedule/dist/schedule.explorer.js:26:14)
at MapIterator.iteratee (/source/project/node_modules/@nestjs/core/hooks/on-module-init.hook.js:21:43)
at MapIterator.next (/source/project/node_modules/iterare/src/map.ts:9:39)
at IteratorWithOperators.next (/source/project/node_modules/iterare/src/iterate.ts:19:28)
at Function.from (<anonymous>)
at IteratorWithOperators.toArray (/source/project/node_modules/iterare/src/iterate.ts:227:22)
at callOperator (/source/project/node_modules/@nestjs/core/hooks/on-module-init.hook.js:22:10)
at Object.callModuleInitHook (/source/project/node_modules/@nestjs/core/hooks/on-module-init.hook.js:42:23)
Expected behavior
The ScheduleExplorer gracefully handles a provider with a null prototype. Could be as simple as returning early if the prototype doesn't exist:
I can open a PR with the above change if it's acceptable.
Minimal reproduction of the problem with instructions
This is reproducible using any provider created with Object.create(null). In my case, it's a custom provider that consists of a proxy where the target is an object created with Object.create(null).
What is the motivation / use case for changing the behavior?
Environment
Nest version:
@nestjs/common: 7.0.2
@nestjs/core: 7.0.2
@nestjs/schedule: 0.3.0
For Tooling issues:
- Node version: v12.16.1
- Platform: Mac
Others:
The text was updated successfully, but these errors were encountered:
I'm submitting a...
Current behavior
The
ScheduleExplorer
will throw an unhandled promise rejection upon module initialization if the discovery service returned any providers that have a null prototype.The provider will make it past the instance check and the error will ultimately be thrown inside the
getAllFilteredMethodNames
method when attempting to access properties of the null prototype:Expected behavior
The
ScheduleExplorer
gracefully handles a provider with a null prototype. Could be as simple as returning early if the prototype doesn't exist:I can open a PR with the above change if it's acceptable.
Minimal reproduction of the problem with instructions
This is reproducible using any provider created with
Object.create(null)
. In my case, it's a custom provider that consists of a proxy where the target is an object created withObject.create(null)
.What is the motivation / use case for changing the behavior?
Environment
The text was updated successfully, but these errors were encountered: