Jump to content
McKay Development

I can't understand why the execution time of Node.js 10s


Recommended Posts

console output:
Login: starlivovsky5 completed successfully

Total accounts connected: 1 from 1
All accounts are successfully connected.
Process Node.js ended with code 0
Function execution time: 10.006s
PS C:\Users\Kast0l\Desktop\tetst script>

Please help me solve this problem or at least understand what it is

const SteamUser = require("steam-user");
const SteamTotp = require("steam-totp");
const accounts = require("./accounts.js");
let totalConnectedAccounts = 0;
const logInAccounts = async () => {
    for (let account of accounts) {
        const client = new SteamUser
        const logInOptions = {
            accountName: account.accountName,
            password: account.password,
            twoFactorCode: SteamTotp.generateAuthCode(account.sharedSecret)
        try {
            await new Promise((resolve, reject) => {
                client.once("loggedOn", () => {
                    console.log(`Login: ${account.accountName} completed successfully`);
                client.once("error", (err) => {
                    console.log(`Ошибка при входе для аккаунта ${account.accountName}: ${err}`);
        } finally {
            await client.logOff();
    console.log(`\nTotal accounts connected: ${totalConnectedAccounts} from ${accounts.length}`);
    console.log("All accounts are successfully connected.");
    console.time("Function execution time");
    process.on('exit', (code) => {
        console.log(`Process Node.js ended with code ${code}`);
        console.timeEnd("Function execution time");
Link to comment
Share on other sites

If there's a request outstanding when you call logOff(), it has to wait for the request to timeout before the Node.js process can exit. There's a bunch of requests that get made internally when you first log on; you're better off waiting a second or so after loggedOn is emitted before calling logOff().

In the future I'll try to add a mechanism to cancel outstanding requests when we log off, but it's not quite as simple as it first sounds.

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.

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.

  • Create New...