-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Nest should not swallow exceptions in NestFactoryStatic.initialize #5162
Comments
Can you please share a minimal repository that shows what you want to accomplish and why this snippet of code is a blocker for you? |
Thanks @kamilmysliwiec, I've created a minimal repository: https://github.com/larose/nest-error-swallow-on-init. It's not a blocker per say as there are ways to detect failures during Nest initialization outside of the process, but this is not convenient. In my case, my Sentry dashboard will show no errors, even though my Nest app doesn't start. Nest should not catch all errors, but let them bubble up instead so the client code can decide what to do with them. |
@kamilmysliwiec, I see that this issue still has the "needs clarification" label. Did my comment above clarified things? |
I think we should add an option named NestFactory.create(AppModule, { abortOnError: false }) Would you like to create a PR for this issue? |
Isn't a better way of doing this would be to provide an interface NestExceptionsHandler an implementation of which can be passed into the options in nestfactory.create() and that exceptionhandler can be used in place of the default exception handler in exceptions-zone.js |
@princechauhan1992 what I've proposed ( |
Sounds good @kamilmysliwiec. @larose @kamilmysliwiec I would like to create a pr for this, if you allow me. |
Sure thing! PRs are more than welcome |
👍 thanks! |
PR #5327 is now merged and released as 7.5.0 |
If an exception is thrown in:
nest/packages/core/nest-factory.ts
Lines 159 to 168 in f0e7597
I don't think there is a way to capture it outside of nest.
Expected behavior
I would expect the exception to bubble up so I can capture it. For example, I'd like to send it to Sentry.
The text was updated successfully, but these errors were encountered: