I would expect the saveData() call in datafx not block anything as there is no "await" but when i check the logs and timestamps i notice that the "main done" log is delayed even though "retrieved data" is not.
async function mainCaller(){
// do something and then trigger call to get data
let id = 13;
let data = await datafx( id ); <-- this gets blocked for saveData() - why?
LOG( `main done` );
}
async function datafx( id ){
// get data
let data = await getData( id );
// cleanup data
// save data but don't wait for it
// datafx does not wait for it as expected
// however, mainCaller() is somehow "delayed" by it based on log timestamps
saveData(id, data );
LOG( `retrieved data` );
return data;
}
async function getData(id){ return await dbRead(id); }
async function saveData(id, data){ return await dbSave(id, data); }
- Is the "await" in the mainCaller() awaiting all async calls, including the nested ones?
- Is that correct?
- Is there a better way to implement the nested async call to avoid the delay on the caller?
- i can confirm that the "saveData()" call is impacting as i removed it and i see the mainCaller continue without delay as soon as datafx returns.