``` async function run() { try { await new Promise(() => { // The executor function finishes, // but it never calls resolve() or reject(). }); } finally { console.log("cleanup"); } } ```
I never expect cleanup to be logged.
One can just wrap os.Exit in a helper to get the expected behaviour.
I certainly wouldn't mind if modern servers had something similar to make sure programs could stop gracefully. But then that doesn't help if you have a hardware failure...
[0] https://learn.microsoft.com/en-us/windows/win32/api/fileapi/...
[1] https://devblogs.microsoft.com/oldnewthing/20170510-00/?p=95...
An unresolved promise that causes other code to be skipped while program execution continues after the block is, well, unintuitive to say the least.