You've written this code. Everyone has:
async function placeOrder ( input : OrderInput ) { const order = await db . orders . insert ( input ); // 1. write to the database await broker . publish ( ' order.placed ' , { id : order . id }); // 2. tell the rest of the system return order ; }
Enter fullscreen mode
Exit fullscreen mode
It looks correct, and it works for months. Then a deploy lands at the wrong moment, the broker has a hiccup, or the process runs out of memory, and the system quietly ends up in a state that makes no sense:
The order exists, but no email was sent, no inventory reserved, no invoice created
Or the event was published for an order that was rolled back and doesn't exist
There is no exception in your logs, just two systems that disagree.…