Sign in
Log inSign up

How do you maintain a consistent state in your Node, Mongo Application?

Saras Arya's photo
Saras Arya
·Feb 21, 2017

I am building a Node app and a problem I face is that somewhere when my server I am running a promise chain, and it breaks due to some parameter being invalid via Mongo or some goddamn reason, the promise chain breaks midway, remaining database calls don't execute, Making it a complete shit storm to come out of.

Solution for this could be various, 1. Better testing, 2. Better design of backend, but I am asking, is there a way to manage state in NodeJS such that if in my series of database calls/promise calls, it fails midway I clean up everything and go back to a clean state. It always stays in one of the determined state and never move away of it.
Has anybody attempted to bring this kind of robustness in their node code?