SteamUser.prototype.logOn = function(details) {
// Delay the actual logon by one tick, so if users call logOn from the error event they won't get a crash because
// they appear to be already logged on (the steamID property is set to null only *after* the error event is emitted)
process.nextTick(async () => {
if (this.steamID) {
throw new Error("Already logged on, cannot log on again");
}
this.steamID = null;
this.limitations = null;
//..........
}
}
after v4.5.1, the logOn method use the nextTick to do login action,
after then, how to get the Error in the nextTick async callback ?
and so, the doConnection is called in the callback method, there are maybe some errors in that method,
for example
function TCPConnection(user) {
this.user = user;
// Pick a CM randomly
if (!user._cmList || !user._cmList.tcp_servers) {
throw new Error("Nothing to connect to: " + (user._cmList ? "no TCP server list" : "no CM list"));
}
let tcpCm = user._cmList.tcp_servers[Math.floor(Math.random() * user._cmList.tcp_servers.length)];
user.emit('debug', 'Connecting to TCP CM: ' + tcpCm);
let cmParts = tcpCm.split(':');
let cmHost = cmParts[0];
let cmPort = parseInt(cmParts[1], 10);
// .......
}
maybe some temporary network issues, and it may cause that, tcpCm is invalid, so
tcpCm.split(':');
may get error,
but those error could not be catched, it cause node.js unhandledRejectionException
how to catch those exception in the code ?