Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in onModuleInit for grpc microservice server not bubbles properly #5135

Closed
danielscw opened this issue Jul 23, 2020 · 1 comment
Closed
Labels
needs triage This issue has not been looked into

Comments

@danielscw
Copy link
Contributor

danielscw commented Jul 23, 2020

Bug Report

Current behavior

Error in onModuleInit doesn't bubble up to listenAsync function

(node:26531) UnhandledPromiseRejectionWarning: Error: error
    at AppService.onModuleInit (/Users/daniel/nest-microservice-onmoduleinit-not-exit-/dist/app.service.js:14:19)
    at MapIterator.iteratee (/Users/daniel/nest-microservice-onmoduleinit-not-exit-/node_modules/@nestjs/core/hooks/on-module-init.hook.js:21:43)
    at MapIterator.next (/Users/daniel/nest-microservice-onmoduleinit-not-exit-/node_modules/iterare/lib/map.js:13:39)
    at IteratorWithOperators.next (/Users/daniel/nest-microservice-onmoduleinit-not-exit-/node_modules/iterare/lib/iterate.js:21:28)
    at Function.from (<anonymous>)
    at IteratorWithOperators.toArray (/Users/daniel/nest-microservice-onmoduleinit-not-exit-/node_modules/iterare/lib/iterate.js:180:22)
    at callOperator (/Users/daniel/nest-microservice-onmoduleinit-not-exit-/node_modules/@nestjs/core/hooks/on-module-init.hook.js:22:10)
    at Object.callModuleInitHook (/Users/daniel/nest-microservice-onmoduleinit-not-exit-/node_modules/@nestjs/core/hooks/on-module-init.hook.js:42:23)
    at NestMicroservice.callInitHook (/Users/daniel/nest-microservice-onmoduleinit-not-exit-/node_modules/@nestjs/core/nest-application-context.js:152:27)
    at NestMicroservice.registerModules (/Users/daniel/nest-microservice-onmoduleinit-not-exit-/node_modules/@nestjs/microservices/nest-microservice.js:45:24)
(node:26531) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:26531) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

check this repo for reproducing the issue

Expected behavior

Error should bubble up to listenAsync function and able to catch it

Possible Solution

https://github.com/nestjs/nest/blob/master/packages/microservices/nest-microservice.ts#L118
registerModules returns a promise but not been handle correctly, should be fine if we handle it properly

Environment

Nest version: 7.1.1
@kamilmysliwiec
Copy link
Member

Fixed in 7.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been looked into
Projects
None yet
Development

No branches or pull requests

2 participants