Closed lovesmurf closed 1 year ago
Works fine for me. Was this happening yesterday during Steam's weekly downtime?
You should always catch errors from anything that could throw one, especially network requests. Errors are always possible when networks are involved.
Works fine for me. Was this happening yesterday during Steam's weekly downtime?
You should always catch errors from anything that could throw one, especially network requests. Errors are always possible when networks are involved.
I noticed that this happens when Steam Logon services are in surge status. But the problem is that the exception is still issued even if I break its processing. Then the process dies accordingly
try {
const webCookies = await session.getWebCookies()
} catch(e) {
return false;
}
Works fine for me. Was this happening yesterday during Steam's weekly downtime?
You should always catch errors from anything that could throw one, especially network requests. Errors are always possible when networks are involved.
It feels like getWebCookies goes into a state of infinite waiting
I can't reproduce this.
try {
session.refreshToken = 'eyAid...';
console.log(await session.getWebCookies());
} catch (ex) {
console.log('getWebCookies() error');
console.log(ex);
}
Output:
getWebCookies() error
Error: Malformed login response
at LoginSession.getWebCookies (path\to\steam-session\src\LoginSession.ts:528:18)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async main (path\to\steam-session\dev\test2.ts:23:15)
That solved my problem.
timeout = setTimeout(() => { return reject(); }, 20000);
let startResult = await session.startWithCredentials({
accountName: bot.login,
password: bot.password,
steamGuardCode: authCode,
});
logger.info("startWithCredentials success");
let timeout = null;
await new Promise((resolve, reject) => {
timeout = setTimeout(() => {
return reject();
}, 20000);
session.on("authenticated", async () => {
console.log("\nAuthenticated successfully! Printing your tokens now...");
console.log(`SteamID: ${session.steamID}`);
console.log(`Account name: ${session.accountName}`);
console.log(`Access token: ${session.accessToken}`);
console.log(`Refresh token: ${session.refreshToken}`);
logger.info("Take webcookies authenticated");
const webCookies = await session.getWebCookies();
logger.info("Taken webcookies success authenticated");
console.log("Web session cookies:");
console.log(webCookies);
community.setCookies(webCookies);
const decodedAccessToken = jwt.decode(session.accessToken);
const decodedRefreshToken = jwt.decode(session.refreshToken);
const accessTokenExpiry = new Date(decodedAccessToken.exp * 1000);
const refreshTokenExpiry = new Date(decodedRefreshToken.exp * 1000);
clearTimeout(timeout);
return resolve();
});
session.on("timeout", () => {
logger.info("[fuck]: timeout");
clearTimeout(timeout);
return reject();
});
session.on("error", err => {
console.log(`ERROR: This login attempt has failed! ${err.message}`);
clearTimeout(timeout);
return reject();
});
});
Now that you've posted your code, I can tell you what's wrong with it.
Throwing an error in an event handler (or rejecting a promise inside an async event handler) does nothing. The error does not get bubbled or caught. You'd need to do this:
session.on("authenticated", async () => {
console.log("\nAuthenticated successfully! Printing your tokens now...");
console.log(`SteamID: ${session.steamID}`);
console.log(`Account name: ${session.accountName}`);
console.log(`Access token: ${session.accessToken}`);
console.log(`Refresh token: ${session.refreshToken}`);
try {
logger.info("Take webcookies authenticated");
const webCookies = await session.getWebCookies();
logger.info("Taken webcookies success authenticated");
console.log("Web session cookies:");
console.log(webCookies);
community.setCookies(webCookies);
} catch (ex) {
reject(ex);
}
const decodedAccessToken = jwt.decode(session.accessToken);
const decodedRefreshToken = jwt.decode(session.refreshToken);
const accessTokenExpiry = new Date(decodedAccessToken.exp * 1000);
const refreshTokenExpiry = new Date(decodedRefreshToken.exp * 1000);
clearTimeout(timeout);
return resolve();
});
Woke up today and found that I was getting a lot of error messages when receiving cookies, then the process dies off. Please tell me, should I always catch catch on getWebCookies function? And what is causing this error?