Jump to content
McKay Development

Exception in logOn( in process.nextTick)


Recommended Posts

Posted
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 ?

Posted

That's a good point on the already logged on error, although for the others I don't really think it's worth being concerned about. It should not be possible to be missing a CM list since it's retrieved from the WebAPI and the library falls back to a bundled list if that fails.

I'll see about making it possible to handle the already logged on error.

  • 2 months later...
Posted
On 9/18/2020 at 3:30 PM, Dr. McKay said:

That's a good point on the already logged on error, although for the others I don't really think it's worth being concerned about. It should not be possible to be missing a CM list since it's retrieved from the WebAPI and the library falls back to a bundled list if that fails.

I'll see about making it possible to handle the already logged on error.

any update for this issue ?
the' already logged' error could not be caughted now, and will cause a crash in the node process

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...