NestJS · Senior · Question 65 of 75
Why can @nestjs/event-emitter handlers run before the database transaction commits?
- 1Handlers run in a separate database
- ✓Correct answer: Events emitted inside a transaction are dispatched immediately; handlers may read uncommitted state or act on a change that later rolls back
- 3Events always wait for commits
Explanation
Emit after commit, or write to an outbox in the same transaction and process it afterwards.