CodePark/ questions / Microservices, queues & events
START PRACTICINGPRACTICE
Backend question · NestJS › Microservices, queues & events

A developer writes this.client.send("create_invoice", dto); in a service without subscribing or awaiting the result. What happens?

Nothing is sent, because send() returns a cold Observable that only dispatches when subscribed

Nothing is sent. ClientProxy.send() returns a cold Observable. Cold means it does nothing until something subscribes, for example with firstValueFrom() or lastValueFrom().

"The message is sent and the response is ignored" is wrong, because the message is never sent at all. "Nest throws because the result isn't awaited" is also wrong. The call compiles and runs without errors, which is why this bug is easy to miss.