Feng's Notes Isn't coding fun?
Posts with the tag NestJS:

A Subtle NestJS Dependency Injection Pitfall: Request-Scoped Providers in Background Workers

Recently our team ran into a production incident caused by a subtle interaction in NestJS’s dependency injection system.

The root cause was a request-scoped provider being injected into a service that was also used by a background worker. At first glance the code looked perfectly valid, but the runtime behavior was very different from what we expected.

This article explains:

  • what happened
  • why it happens in NestJS
  • how dependency scope propagation works
  • how to design services to avoid this class of issue