How do you tackle race condition in NodeJS?
I am building an IoT application which sends me data packets every 15 secs. Now I am using a data structure to store the relevant info in my Database(mongodb) that is coming from packets and use it subsequently in functions. The problem I am facing is, when I am sending my packets very fast(milliseconds) or even say 1-2 sec fast, my program crashes as value required for processing next packet is dependent on results of previous packet. This is aggrevated more when I using more number of cores as latest packet run on different cores having different cycles. Has anybody faced a similar kind of problem? I am ready for a hangouts session if somebody is interested to look at the code and then decide what is the real issue.