-
Notifications
You must be signed in to change notification settings - Fork 512
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
ErrorHandlerMiddleware is ignore with 6.1.* #1598
Comments
Hello there VincentClair 👋 Thank you for opening your very first issue in this project. We will try to get back to you as soon as we can.👀 |
Code example :
|
Find the soluton : put buildPromise inside try/catch tsoa/packages/runtime/src/routeGeneration/templates/express/expressTemplateService.ts Line 41 in efdb468
|
@VincentClair thank you for locate the missing part, could you submit a PR including test cases let tsoa prevent such issue in the future? |
@jackey8616 have you an advice how to test this case ? |
Yes, you should add one test case in express, koa, hapi integration test. You can take fixtures/getController.ts as example, duplicate the method with throwing an error and add handle case in .spec.ts of 3 of that framework. |
Sorry, but i haven't find a way to add a proper test and I have no more time to pass on it. It seems the solution has to be completed: when we use inversify (and probably all other solutions ?) we have to await for apiHandler to execute, so errors could be catched and pass to next(err). Otherwise, errors could pass through tr/catch due to async code.
|
Never mind, I will take rest of things, thanks for your informations. |
@VincentClair |
Finally found the problem: if the throwing method is not async, error is neither caught by I have made a PR #1602 |
@WoH When did you plan to publish the fix please ? |
Sorting
I'm submitting a ...
I confirm that I
Expected Behavior
When an error is thrown, custom ErrorHandlerMiddleware catches the error and returns a response with according errorCode (400, 403, 429, etc.). Works as expected with 6.0.*
Current Behavior
When an error is thrown, custom ErrorHandlerMiddleware is ignore and app hangs up, nothing happens. Breaks with upgrade to 6.1.4 and 6.1.5, and routes regenerated.
Context (Environment)
Version of the library: 6.1.*
Version of NodeJS: 20.*
Breaking change?
It seems that is related to the new way of generated routes that handles requests.
I have passed many hours to debug, but does not find something really more helpfull. Sorry !
The text was updated successfully, but these errors were encountered: