On the memory release of Promise

The

Promise (fun_father) function contains the Promise (fun_son) function. If fun_father starts with resolve () and the fun_son is not finished, will the fun_son continue or terminate?

let status= 0
const fun_father= () => {
    return new Promise((resolve, reject) => {
        fun_son().then(() => {
            status= 1
        })
        //......
            resolve("fun_father done")
    }) 
}

const fun_son = () => {
    return new Promise((resolve ,reject) => {
        //......
            resolve("fun_son done")
    })
}

fun_father().then(msg => {
    console.log(msg)
})

I encounter this situation when writing a project. After simplification, it is similar to the above. I want to be able to print out "fun_father done" and change the status to 1. After writing this, the leader told me that it would be fine if fun_son executed faster than fun_father, but if otherwise, fun_son would terminate execution because fun_father returned and memory was freed. I still have doubts about this, but if I try it myself, there is no good way to test async (loops are useless). SetTimeout is OK, but it can"t be fully explained. Therefore, I would like to ask the bosses whether this method of writing is feasible.

May.18,2022

there's nothing wrong with the code


according to your current code, fun_son will continue to execute;

< hr >

add:
what your leader means is that it is not good for you to write code like this. If fun_father resolve needs to be used immediately after status , there will be uncertainty.
you can slightly change the code of fun_father :

  

there is no release at the js level

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3d02d-2b6c1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3d02d-2b6c1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?