I’m not even close to being a NodeJS expert, but I think the deep answer to your question is in this presentation. It’s deep, but very informative about the underlying event loop in Node.
Node keeps track of the active things happening in your code, and when there is nothing else happening, it simply exits. I think this is what you may be seeing; a promise that never resolves. As such, a try-catch will not see that which is unresolved.
As I’ve gleaned from far smarter developers than muself, Node keeps a reference count of things like timers and network requests. When you make a network, or other async request, set a timer, etc. Node adds on to this ref count. When the times/request resolve, Node subtracts from the count. This count is how Node decides whether to exit at the end of the event loop. When you get to the end of the event loop Node looks at this count and if it’s zero exits.
I ran into this issue, running npx coda execute on a terminal window in VS Code (in case it matters). After trying a bunch of different ways to wait on promises, and all of them hanging Eric suggested that I run the command with the --vm=false flag set, and that made it stop hanging and work as expected.
Your results may vary and I can’t say definitely this is the solution but I thought I would post what helped me. I hope it fixes your problem as well.
Diving in deeper, it seems like something broke when the VM package we are using (isolated-vm) released their latest version. I’ve raised the issue with our engineering team, but in the mean time disabling the VM is a good workaround.