UPDATE: Added a try catch block around the problematic code and it doesn't enter the catch block nor the finally block. It just exits. So, i've been trying to get this page to work. After reading about it on this question and trying to implement several similar approaches, somehow my page crashes. After using chrome's F12 to go step by step, I've found out that its when I call the sleepNow that it goes to create the new Promise that makes JS crash and the execution stops.
async function validateDates(){
<code>
var settings = 'dialogwidth:292px;dialogheight:140px;status:no;help:no;resizable:no;menubar:no;toolbar:no;';
var popup = function_that_opens_window("random.jsp?scoIdlist="<VARS SET IN CODE>",window,settings);
try {
const sleepNow = (delay) => new Promise((resolve) => setTimeout(resolve, delay));
while(popup && !popup.closed){
await sleepNow(1000);
}
}
catch(err) {
alert("ERROR: "+ err.message);
}
finally{
alert("no error: ");
}
}
Anyone has any idea how that's happening or why? Thanks in advance