Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
HarryVGI opened this issue Dec 20, 2024 · 2 comments
Labels

Comments

@HarryVGI
Copy link
Contributor

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/  
@HarryVGI HarryVGI added the bug label Dec 20, 2024
@DoctorMcKay
Copy link
Owner

This is expected behavior, it continually re-attempts to connect if it encounters a network error while connecting.

@HarryVGI
Copy link
Contributor Author

Hmm, interesting. Then that's where I have the issue -- it's not re-attempting, instead getting stuck with the [WebAPI] Using cached value for API_GET_https://api.steampowered.com/ISteamDirectory/GetCMListForConnect/v0001/ line.

So, I'm waiting for the loggedOn event, but when it gets an error like this, then it just gets stuck on that last debug line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants