DoctorMcKay / node-steam-user

Allows interaction with the Steam network via the Steam client protocol
https://dev.doctormckay.com/forum/7-node-steam-user/
MIT License
888 stars 157 forks source link

Uncaught exception at steam-user#webLogOn() #487

Closed nolddor closed 2 months ago

nolddor commented 3 months ago

Describe the bug

A fatal error was thrown and not caught at today's log after session expired:

[2024-08-03 02:02:22] [Auth] The steamcommunity.com web session has expired. Re-connecting...     

node_modules/steam-session/dist/helpers.js:14                                                                                                            
    let err = new Error(errorMessage || resultMsg);                                                                                                                                      
              ^                                                                                                                                                                          

Error: Timeout                                                                                                                                                                           
    at eresultError (node_modules/steam-session/dist/helpers.js:14:15)                                                                                   
    at AuthenticationClient.sendRequest (node_modules/steam-session/dist/AuthenticationClient.js:242:46)                                                 
    at async AuthenticationClient.generateAccessTokenForApp (node_modules/steam-session/dist/AuthenticationClient.js:210:22)                             
    at async LoginSession.refreshAccessToken (node_modules/steam-session/dist/LoginSession.js:761:29)                                                    
    at async LoginSession.getWebCookies (node_modules/steam-session/dist/LoginSession.js:670:17) {                                                       
  eresult: 16                                                                                                                                                                            
}   

Faulty code at my side was:

Bot.prototype.onWebSessionExpired = function() {
    /*
     * We cannot log onto steamcommunity.com without first being connected to Steam network,
     * If we are not connected to Steam network, then client.steamID is not set
     * Further info at https://dev.doctormckay.com/topic/2213-cannot-log-onto-steamcommunitycom-without-first-being-connected-to-steam-network/?tab=comments#comment-7292
     */
    if(this.client.steamID) {
        logger.debug('The steamcommunity.com web session has expired. Re-connecting...', { component: 'Auth' })
        this.client.webLogOn()
    }
}

wiki docs says there is no promise or callback to catch errors: imagen

Versions

head node_modules/steam-user/package.json 
{
        "name": "steam-user",
        "version": "5.0.10",
        "description": "Steam client for Individual and AnonUser Steam account types",
        "keywords": [
                "steam",
                "steam client",
                "steam user"
        ],
        "homepage": "https://github.com/DoctorMcKay/node-steam-user",
head node_modules/steam-session/package.json 
{
        "name": "steam-session",
        "version": "1.7.2",
        "description": "Enables authenticating with Steam",
        "keywords": [
                "steam"
        ],
        "homepage": "https://github.com/DoctorMcKay/node-steam-session",
        "bugs": {
                "url": "https://github.com/DoctorMcKay/node-steam-session/issues"
node -v
v20.13.1

npm -v
10.5.2

Screenshots and Error Logs

N/A

nolddor commented 3 months ago

@DoctorMcKay let me know if you need further details, thx.

DoctorMcKay commented 2 months ago

Fixed in 5.1.0