Skip to content

client.on('error') doesn't emit errors while errors are visible in 'debug' logs #507

@HarryVGI

Description

@HarryVGI

Describe the bug

The client.on('error', (error: Error) => {}) event handler is no longer emitting errors. However, the errors can still be observed when using client.on('debug', (msg: any) => {}).

Versions

Using steam-user version 5.2.0 and node version 22.11.0.

Code

const client = new SteamUser({
  httpProxy: getProxyUrl(),
});
client.on('debug', (msg: any) => console.log(msg));
const loggedOnPromise = new Promise<any>((resolve, reject) => {
  client.on('error', (error: Error) => {
    console.log(`Error from SteamUser: ${error?.name} - ${error?.message}`);
    reject(error);
  });
  console.log(`Added error listener to SteamUser`);
  client.on('loggedOn', () => {
    console.log(
      `Logged into Steam as anon: ${this.currentId}; with public IP ${this.currentPublicIp}`
    );
    resolve(client);
  });

  client.on(
    'disconnected',
    (eresult: EResult, msg?: string | undefined) => {
      console.log(
        `logged off anon user with EResult ${eresult}(${SteamEResult.getName(
          eresult
        )}) reason '${msg}'`
      );
    }
  );

});

client.logOn({ anonymous: true });

Screenshots and Error Logs

Normal debug log example:

API GET request to https://api.steampowered.com/ISteamDirectory/GetCMListForConnect/v0001/?format=vdf&cellid=20: 200  
Randomly chose websockets server cmp1-iad1.steamserver.net:27020 (load = 14, wtd_load = 46.9086670875549316)  
[W403] Connecting to WebSocket CM cmp1-iad1.steamserver.net:27020  
WebSocket connection success; now logging in  
Sending message: ClientLogon  
[W403#1] Unhandled message: ClientServersAvailable  
[W403#1] Handled message: ClientLogOnResponse (OK)  
Handle logon response (OK)  
Logged into Steam as anon: redacted  

debug log example with error:

API GET request to https://api.steampowered.com/ISteamDirectory/GetCMListForConnect/v0001/?format=vdf&cellid=20: 200  
Randomly chose websockets server cmp1-iad1.steamserver.net:27018 (load = 15, wtd_load = 50.467526912689209)  
[W404] Connecting to WebSocket CM cmp1-iad1.steamserver.net:27018  
[W404] WebSocket disconnected with error: Proxy CONNECT 502 Bad Gateway  
[W404] Handling connection close  
[WebAPI] Using cached value for API_GET_https://api.steampowered.com/ISteamDirectory/GetCMListForConnect/v0001/  

another example with error in debug log:

API GET request to https://api.steampowered.com/ISteamDirectory/GetCMListForConnect/v0001/?format=vdf&cellid=85: 200  
Randomly chose websockets server cmp1-lhr1.steamserver.net:27020 (load = 12, wtd_load = 6.38670492172241211)  
[W29] Connecting to WebSocket CM cmp1-lhr1.steamserver.net:27020  
[W29] WebSocket disconnected with error: Client network socket disconnected before secure TLS connection was established  
[W29] Handling connection close  
[WebAPI] Using cached value for API_GET_https://api.steampowered.com/ISteamDirectory/GetCMListForConnect/v0001/  

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions