Node.js Promise concurrency

40 Views Asked by At

I am getting a weird unexpected output that I can't explain.

knowing that I am using Node.js and MongoDb, take a look at this code below (i): enter image description here

is supposed to be faster then this code below (ii): enter image description here

but weird enough I get this output in the console: enter image description here

even though I am running block (i) before running block (ii), and if I switch those 2 blocks so that block (ii) gets executed before (i), this is what I get: enter image description here and sometimes I get 'seedRoles in NAN' in this case.

Can anyone explain this behavior in Node.js ?

0

There are 0 best solutions below