Jump to content
McKay Development

Already logged on, cannot log on again (with only 1 call to .logOn per instance)


adam1

Recommended Posts

const getAppBranchInfo = (appId, branch) => new Promise(resolve => {
    let user = new SteamUser();

    user.on('loggedOn', async () => {
        const productInfo = await user.getProductInfo([appId], []);
        const appName = productInfo.apps[appId].appinfo.common.name;
        const buildId = productInfo.apps[appId].appinfo.depots.branches[branch].buildid;
        const timeUpdated = productInfo.apps[appId].appinfo.depots.branches[branch].timeupdated;

        // Graefully logoff.
        user.logOff();
        resolve({
            appName: appName,
            buildId: buildId,
            timeUpdated: timeUpdated
        });
    });

    user.logOn();
});

const job = schedule.scheduleJob('*/3 * * * * *', () => {
    console.log(formatDate());
    getAppBranchInfo(740, 'public')
    .then(info => {
        // [...]
    });
});

This ran for several hours before:

Feb 7 @ 05:37:21 (UTC)
/Users/user/git/app/node_modules/steam-user/components/logon.js:23
                        throw new Error("Already logged on, cannot log on again");
                              ^

Error: Already logged on, cannot log on again
    at /Users/user/git/app/node_modules/steam-user/components/logon.js:23:10

The only thing I can think of is that attempting to login anonymously every 3 seconds is too often, but surely it's not possible to already be logged in?

Link to comment
Share on other sites

Can I see the rest of the stack trace, please? It's possible that there's a bug in the module.

This isn't related to the error, but I don't see any reason why you'd need to log on anonymously every time you want to send that request. You could just leave the connection open and you might run into fewer issues with Steam throttling you or something.

Link to comment
Share on other sites

On 2/9/2021 at 7:37 AM, Dr. McKay said:

Can I see the rest of the stack trace, please? It's possible that there's a bug in the module.

This isn't related to the error, but I don't see any reason why you'd need to log on anonymously every time you want to send that request. You could just leave the connection open and you might run into fewer issues with Steam throttling you or something.

Hey, sure. If I change my job to run every second I can get it to happen within a minute or so usually:

Feb 10 @ 08:07:17 (UTC)
/Users/user/git/app/node_modules/steam-user/components/logon.js:23
                        throw new Error("Already logged on, cannot log on again");
                              ^

Error: Already logged on, cannot log on again
    at /Users/user/git/app/node_modules/steam-user/components/logon.js:23:10
    at processTicksAndRejections (node:internal/process/task_queues:75:11)

 

Link to comment
Share on other sites

const SteamUser = require('./index.js');

let instance = 0;

const getAppBranchInfo = (appId, branch) => new Promise(resolve => {
	let user = new SteamUser();
	let inst = ++instance;

	user.on('loggedOn', async () => {
		console.log(inst + ' logged on');
		const productInfo = await user.getProductInfo([appId], []);
		const appName = productInfo.apps[appId].appinfo.common.name;
		const buildId = productInfo.apps[appId].appinfo.depots.branches[branch].buildid;
		const timeUpdated = productInfo.apps[appId].appinfo.depots.branches[branch].timeupdated;
		console.log(inst + ' ' + buildId);

		// Graefully logoff.
		user.logOff();
		resolve({
			appName: appName,
			buildId: buildId,
			timeUpdated: timeUpdated
		});
	});

	user.logOn();
});

setInterval(() => getAppBranchInfo(740, 'public'), 1000);

I ran this for 5 minutes and it didn't crash. What version of steam-user are you on?

Link to comment
Share on other sites

10 hours ago, Dr. McKay said:

I ran this for 5 minutes and it didn't crash. What version of steam-user are you on?

Hi, thanks for trying it out. I'm running `4.19.3` at the moment. Although when I tried this again today I had to leave it running for quite some time to generate an error... 6 hours roughly. I did get a slightly longer stack trace this time. I'm usually running it in a screen so I worry that might be chopping the stack trace off.

/Users/user/git/app/node_modules/steam-user/components/logon.js:23
                        throw new Error("Already logged on, cannot log on again");
                              ^

Error: Already logged on, cannot log on again
    at /Users/user/git/app/node_modules/steam-user/components/logon.js:23:10
    at processTicksAndRejections (node:internal/process/task_queues:75:11)
    at runNextTicks (node:internal/process/task_queues:62:3)
    at listOnTimeout (node:internal/timers:525:9)
    at processTimers (node:internal/timers:499:7)

 

Edited by adam1
Link to comment
Share on other sites

  • 2 weeks later...

Yeah... I really am not sure about the best way to approach this. It's necessary to use process.nextTick in order to avoid errors caused by calling logOn inside of an error callback, meaning that the thrown Error can't be caught. But I also don't like the idea of using the error event for this, since when this error occurs, the client actually still is logged on and the error event always indicates that the client has disconnected...

Link to comment
Share on other sites

3 hours ago, Dr. McKay said:

Yeah... I really am not sure about the best way to approach this. It's necessary to use process.nextTick in order to avoid errors caused by calling logOn inside of an error callback, meaning that the thrown Error can't be caught. But I also don't like the idea of using the error event for this, since when this error occurs, the client actually still is logged on and the error event always indicates that the client has disconnected...

I'll keep an eye on this thread, hope you can come up with a solution. Right now I've implemented a pretty nasty workaround.

process.on('uncaughtException', error => {
    if (error.message === 'Already logged on, cannot log on again') {
        console.error(error.message);
        return;
    }

    throw error;
});

 

Link to comment
Share on other sites

  • 1 year later...
On 2/26/2021 at 5:53 AM, adam1 said:

I'll keep an eye on this thread, hope you can come up with a solution. Right now I've implemented a pretty nasty workaround.

Hello, can someone help me i get same error after 100 seconds of running 

/app/node_modules/steam-user/components/logon.js:10

 

Thank you

Link to comment
Share on other sites

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...