Assume I have a request:

```js
app.post('/order', ()=>{
 // task 1
 // task 2
 // task 3
})

```

and `task1` and `task2` is completed but `task3` failed.  

for example a user paid order successfully but saving order in database fails.  

specially in node.js application that global environment is shared among all http clients and if app crashes, all other http request will be unfinished.  

What are best practices to lower damages by such secnario?