Skip to content

Instantly share code, notes, and snippets.

@tbranyen
Created February 20, 2019 01:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbranyen/c74f7ca6678d1739eeccbdd61210c322 to your computer and use it in GitHub Desktop.
Save tbranyen/c74f7ca6678d1739eeccbdd61210c322 to your computer and use it in GitHub Desktop.
function makePromise() {
return new Promise(() => {});
}
async function main() {
console.log('start');
await makePromise();
console.log('end');
}
main();
@tbranyen
Copy link
Author

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
Copy link
Author

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

@fabiancook
Copy link

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
Copy link

padmaia 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