node-steam-session: Unhandled rejection: 'Proxy connection timed out' causes app crash
Describe the bug
When using a proxy, the “Proxy connection timed out” exception sometimes occurred. Try/catch does not catch this exception.
Versions
steam-session: 1.2.3 node: v18.16.0
Code
const getCookies = async (refreshToken: string, proxy: string) => {
let loginSession: LoginSession;
try {
loginSession = new LoginSession(EAuthTokenPlatformType.WebBrowser, { httpProxy: proxy });
loginSession.loginTimeout = 10000;
loginSession.refreshToken = refreshToken;
const cookies = await loginSession.getWebCookies();
return cookies;
} catch (error) {
throw new Error('Failed to get cookies');
} finally {
loginSession?.cancelLoginAttempt();
}
};
Screenshots and Error Logs
Error: Proxy connection timed out
at ClientRequest.<anonymous> (/Users/user/Progects/project/node_modules/@doctormckay/stdlib/src/lib/http/proxyagent.ts:106:18)
at ClientRequest.emit (node:events:513:28)
at ClientRequest.emit (node:domain:489:12)
at Socket.emitRequestTimeout (node:_http_client:848:9)
at Object.onceWrapper (node:events:627:28)
at Socket.emit (node:events:525:35)
at Socket.emit (node:domain:489:12)
at Socket._onTimeout (node:net:570:8)
at listOnTimeout (node:internal/timers:569:17)
at processTimers (node:internal/timers:512:7) {
proxyConnecting: true
}
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 18 (12 by maintainers)
Where the error event is attached shouldn’t be an issue here. Assuming no bug in the library, it’s possible that the error is originating from the getWebCookies() call, since that isn’t wrapped in try/catch.
@ivandrago228
in your code example there is an error
session.on('authenticated'...fires later than try/catch block endsso, you’re not properly handle errors in event block