Skip to content

Instantly share code, notes, and snippets.

@tbranyen tbranyen/awhat.js
Created Feb 20, 2019

Embed
What would you like to do?
function makePromise() {
return new Promise(() => {});
}
async function main() {
console.log('start');
await makePromise();
console.log('end');
}
main();
@tbranyen

This comment has been minimized.

Copy link
Owner Author

commented Feb 20, 2019

Why does Node log start and exit immediately? Shouldn't it keep the process alive, waiting for the promise to resolve (which it never will)?

@tbranyen

This comment has been minimized.

Copy link
Owner Author

commented Feb 20, 2019

Issue described in Node's issue tracker: nodejs/node#22088

@fabiancook

This comment has been minimized.

Copy link

commented Feb 20, 2019

As far as I know, as soon as that event loop is cleared that's the end of the process.

Because nothing is going to ever run after the promise is fulfilled there is nothing in the event loop to be done.

@padmaia

This comment has been minimized.

Copy link

commented Feb 21, 2019

Oh my god, I'm pretty sure I ran into this for the first time a couple weeks ago! Thought I was going crazy, but like always my assumptions were just wrong. Thanks for giving me my sanity back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.