Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
let flag = true;
async function frozen(promise) {
flag = await promise;
console.info("done");
}
let complete = null;
frozen(new Promise((reply, reject) => {
complete = reply;
}));
// you'll never see 'done'
complete(false);
// even after you complete the promise
// because js may keep a promise on the event loop
// even if it was completed on the same 'thread'
while (flag) {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment