Application Events in NestJS, for Spring Developers: Rolled Back, Receipt Sent

1 October 2026 nestjstypescriptnodejsjavaspring-bootevents
PDF The design sheet The full architecture and the verified references. Free, no email.
Thumbnail for Application Events in NestJS, for Spring Developers: Rolled Back, Receipt Sent 3:49
Watch on YouTube, or read on below.
Run this yourself → Clone the repo, docker compose up, and watch it happen

A payment is declined and the transaction rolls back. The payment is not in the database, and the customer still got a receipt email. That happened on Spring Boot with a plain @EventListener and on NestJS with @OnEvent, measured on 1 October 2026 against Postgres. Publishing inside a transaction does not make the event transactional.

Who hears a failure

A Spring listener that throws threw straight back to publishEvent. A Nest listener that throws, sync or async, was caught and logged, and emit() did not throw. With suppressErrors: false, an async listener’s error was not caught at all: the process exited, 18 ms in.

Who waits

With a 300 ms listener, Spring’s publishEvent returned after 303 ms, and after 1 ms with @Async. Nest’s emit() returned at 7 ms while the listener ran to 307 ms; emitAsync() waited 302 ms. Only emitAsync with suppressErrors: false handed the listener’s error back to the publisher.

The transaction

Spring’s @TransactionalEventListener did not run on rollback and ran after the commit when it committed. Nest’s @OnEvent ran inside the open transaction. The fix on Nest is to emit after the commit, and to use an outbox when the event must survive a crash between the two.

The full code for every measurement is in the repository, and the free design sheet above has the checklist on one page.


Watch next

New videos land on Code with Sam - subscribe there if this was useful.

Get the interview pack

A free, practical pack for engineers preparing for senior backend interviews - the questions that actually get asked, and how to answer them like someone who has done the work.

New articles and videos when they land. No spam, and one click to leave.