#default exception result in crash

10 messages · Page 1 of 1 (latest)

arctic dove
#

hi, I call throw new UnauthorizedException() in my passport strategy. this results in a server crash:

HttpException: Invalid credentials
    at ...dist/apps/may-server/webpack:/src/app/auth/auth.strategy.ts:38:19
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

I cant find any configuration that would overwrite the default behavior of nest in this case.

I use nestjs 10.2.5 and node 18.17.1

Dose someone have an idea why this could happen?

#

I was able to fix this by using app.useGlobalFilters(new BaseExceptionFilter()); but I'm not sure, why i need to do this manually

empty crater
#

That generally shouldn't cause a crash. Can you provide a reproduction?

arctic dove
#

I tried with a fresh project, everything worked fine. as I dont know what caused this problem, I dont know how to reproduce it 😕

empty crater
#

Are you using a monorepo? Can you share your original code?

arctic dove
#

its an nx project. unfortunatly its code under nda. I will try to figure something out

empty crater
#

Hmm, nx monorepos usually are single package version, so this should be fine

untold copper
#

Most likely some missing await on a promise

empty crater
#

That was my initial thought,. Strange that adding a global filter would fix it though

arctic dove
#

hi, wasn't able to reproduce it at the time, since i solved it, I probably could now.

We use Graphql and a custom Passport startegy. the corresponding Guard is set globally.
in the passport, we had thrown this exception. But the passoport exception are not handeld by the Basefilder in a Graphql context. This behavior was found in some random issue and not in the Graphql doc part. We now use this.success and this.fail from the import { Strategy } from 'passport-strategy';