I had a promise chain that looked something like this.
fistAsyncFunction()
.then(() => {
secondAsyncFunction()
})
.then(() => {
thirdAsyncFunction()
})
I noticed that the third async function was starting before the second async function finished, but after changing it to this, it worked how I wanted it to.
fistAsyncFunction()
.then(() => {
return secondAsyncFunction()
})
.then(() => {
thirdAsyncFunction()
})
It seems like even though the second async function didn't return anything, the program waited for it to return undefined before moving onto the next promise. Is this what's actually happening? If not, then what is going on under the hood that prompts javascript to start executing the next promise?