Skip to content

LaurynasGr/nestjs-saga-error-demo

Repository files navigation

Setup

  • Clone the repo
git clone https://github.com/LaurynasGr/nestjs-saga-error-demo.git
  • Go into the folder and install dependencies
cd nestjs-saga-error-demo && npm i
  • Run the development server
npm run start:dev

NestJS Saga Error Examples

Normal activity:

No errors in this case - all events and actions are performed as expected.

Error thrown in command handler:

This error is thrown in a NotifyAdminsCommandHandler that's being triggered by UserSagas. The error is handled by NestJS and logged to the console. Error handling works as expected.

Error thrown directly in a saga:

This error is thrown in UserSagas directly (same error as above). The error causes the app to crash. The below code can be uncommented in main.ts. The issue here is that this will prevent the app from crashing but it would also prevent the saga from ever being triggered again after the first time it throws.

// process.on('uncaughtException', (err) => {
//   console.error('Application encountered an uncaught exception:', err);
// });

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published