Closed marefati110 closed 2 years ago
this is expected as you didn't use await
(or handled any error) in the promise returned by AppService#getHello
.
in same scenario with an other project with older version of nest i get this output
what is ExceptionsHandler
is guess its not in version 9
[Nest] 84235 - 07/17/2022, 12:20:05 AM ERROR [ExceptionsHandler] undefined is not iterable (cannot read property Symbol(Symbol.iterator))
TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
at /home/doctop/doctop/doctop-nestjs/src/common/interceptors/reshape.interceptor.ts:77:39
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at /home/doctop/doctop/doctop-nestjs/src/common/interceptors/custom-serializer.interceptor.ts:57:16
[Nest] 84235 - 07/17/2022, 12:20:05 AM ERROR [API] GET /v1/host/sitemap 500 333ms
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(). The promise rejected with the reason:
BadGatewayException: Bad Gateway
at HostService.hostSiteMap (/home/doctop/doctop/doctop-nestjs/src/app/site-generator/service/host.service.ts:77:11)
at HostController.getHostSitMap (/home/doctop/doctop/doctop-nestjs/src/app/site-generator/controller/host.controller.ts:22:22)
at /home/doctop/doctop/doctop-nestjs/node_modules/@nestjs/core/router/router-execution-context.js:38:29
at InterceptorsConsumer.transformDeferred (/home/doctop/doctop/doctop-nestjs/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:31:33)
at /home/doctop/doctop/doctop-nestjs/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:15:53
at Observable._subscribe (/home/doctop/doctop/doctop-nestjs/node_modules/rxjs/src/internal/observable/defer.ts:53:15)
at Observable._trySubscribe (/home/doctop/doctop/doctop-nestjs/node_modules/rxjs/src/internal/Observable.ts:244:19)
at /home/doctop/doctop/doctop-nestjs/node_modules/rxjs/src/internal/Observable.ts:234:18
at Object.errorContext (/home/doctop/doctop/doctop-nestjs/node_modules/rxjs/src/internal/util/errorContext.ts:29:5)
at Observable.subscribe (/home/doctop/doctop/doctop-nestjs/node_modules/rxjs/src/internal/Observable.ts:220:5)
at doInnerSub (/home/doctop/doctop/doctop-nestjs/node_modules/rxjs/src/internal/operators/mergeInternals.ts:71:40)
at outerNext (/home/doctop/doctop/doctop-nestjs/node_modules/rxjs/src/internal/operators/mergeInternals.ts:53:58)
at OperatorSubscriber._this._next (/home/doctop/doctop/doctop-nestjs/node_modules/rxjs/src/internal/operators/OperatorSubscriber.ts:43:13)
at OperatorSubscriber.Subscriber.next (/home/doctop/doctop/doctop-nestjs/node_modules/rxjs/src/internal/Subscriber.ts:75:12)
at /home/doctop/doctop/doctop-nestjs/node_modules/rxjs/src/internal/observable/innerFrom.ts:89:24
at processTicksAndRejections (node:internal/process/task_queues:96:5)
@micalevisk
are you using the same nodejs version in both? which version?
yes nodejs v16.16.0
@micalevisk
I guess we can't help you on that other project without the source.
For the repro you've shared, in node16 your app will crash because nestjs doesn't handle rejections on "floating" promises. And this is expected.
do you have and idea to how i can stop killing process on error ? change nodejs version or what ?... thanks @micalevisk
just add an await
in there. Spend some time learning nodejs. Nestjs doesn't replaces Node.
I found that this code is used to prevent kill process in main.js
process.on('unhandledRejection', (error) => {
console.error(error);
});
thsnk for your help
@micalevisk
another resource on this subject: Let It Crash: Best Practices for Handling Node.js Errors on Shutdown
another resource on this subject: Let It Crash: Best Practices for Handling Node.js Errors on Shutdown
thanks
Is there an existing issue for this?
Current behavior
nestjs process exit when an error happern in an async function (without await) like this
i create a new project and use fasrify and also try to use
errors.interceptor.ts
https://docs.nestjs.com/interceptors but notworkscontroller
service
ouput
Minimum reproduction code
https://stackblitz.com/edit/nestjs-typescript-starter-3fwqre?file=src/app.controller.ts
Steps to reproduce
1 - oppen link https://stackblitz.com/edit/nestjs-typescript-starter-3fwqre?file=src/app.controller.ts 2 - yarn install 3 - yarn start 4 - refresh page
Expected behavior
Expected internal server error
Package
Other package
No response
NestJS version
9.0.3
Packages versions
Node.js version
16
In which operating systems have you tested?
Other
No response