While constructing a new apex object errors occurring establishing the web socket connection are uncaught. For example:
try {
const myapex = new APEX('bad-url');
}
catch (e) {
// the above error can't be caught here because the error throws from a different thread.
}
It is also a questionable practice to perform an async operation in a constructor. It would probably be better to have a separate connect routine which is async. This would make handling errors easier too. Now the only way I could catch the error thrown above was in the process.on('uncaughtException').