client.on('error') doesn't emit errors while errors are visible in 'debug' logs
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/
This is expected behavior, it continually re-attempts to connect if it encounters a network error while connecting.
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.
Looks like it's my case. After updating, now I'm stuck at
[WebAPI] Using cached value for API_GET_https://api.steampowered.com/ISteamDirectory/GetCMListForConnect/v0001/
And auth does not go forward...
Latest not affected version is 5.0.9
Facing same issue as described by @T1MOXA or @HarryVGI, tracking this at #512
Same problem here. It just stuck in Using cached value
Edit: I am using Bun and I was able to fix this with: NODE_TLS_REJECT_UNAUTHORIZED=0 bun ./index.ts