-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Exceptions thrown on async providers in Request scope are not handled. #2290
Comments
You cannot apply exception filters to the custom providers. Your async providers should never throw exceptions, just put this logic elsewhere |
Even for providers in Request Scope :( . I understand the service resolution on application start up but on request context, service resolution should be able to gracefully fail. |
Let me reopen this and look at the best possible solution |
@kamilmysliwiec thank you that would be great, this simplifies a lot use cases when you need to decide on run time (based on user/feature etc) what service to pass to the controller. |
Fixed in 6.4.0. Keep in mind that these exceptions will be catchable only by statically scoped exception filters :) |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug Report
maybe related to
#1126
#761
Current behavior
When routes with async providers are used request crashes and client never gets any response.
Error shows up as UnhandledPromiseRejectionWarning in console
Input Code
replication repo
https://github.com/dynamikus/replicate-nestjs-request-scope-usefactory-error
Expected behavior
Errors thrown from async provider should buble up to the global exception handler. So we can gracefully respond to the client.
Possible Solution
Sorry tried to be able to figure out for a solution but I am not familiar with nestjs core.
Error bubbles up to here
https://github.com/nestjs/nest/blob/master/packages/core/router/router-explorer.ts#L195
We need to wrap with try and catch the handler method and apply the exception filter (which I am not sure what the correct nestjs to handle this. :( )
I monkey patched a solution but I am not sure if this is the proper nestjs way to handle this. Let me know
if this approach is Ok and I will open a pr.
Environment
The text was updated successfully, but these errors were encountered: