I have this strange problem with the code below: adding an infinite loop after a function call will prevent promises from resolving, inside the call.
I don't understand why, and how this loop can influence promise behaviour
const second_call = () => {
return new Promise((resolve, reject) => {
console.log("Second call");
resolve();
});
}
const first_call = () => {
console.log("First call");
second_call().then(() => {
console.log("First call, THEN");
});
}
const main = () => {
console.log("Started");
first_call();
//if if comment the while (true), all debug msgs will be displayed
//if i uncomment the while (true), the msg "First call, THEN" will not be displayed
while (true);
}
main();