Skip to content

Commit

Permalink
Fix a crash if the server connection times out
Browse files Browse the repository at this point in the history
  • Loading branch information
tiennou committed Sep 30, 2024
1 parent c9b2194 commit 12a2fc1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/pushStats/apiFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async function req(options) {
return Promise.race([executeReq, maxTime])
.then((result) => {
if (result === 'Timeout') {
logger.log('info', 'Timeout hit!', new Date(), JSON.stringify(options), reqBody);
logger.log('info', { data: 'Timeout hit!', options });
return undefined;
}
if (typeof result === 'string' && result.startsWith('Rate limit exceeded')) {
Expand Down
4 changes: 4 additions & 0 deletions src/pushStats/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ class ManageStats {
? await ApiFunc.getMemory(userinfo, shard)
: await ApiFunc.getSegmentMemory(userinfo, shard);

if (!stats) {
logger.error(`Failed to grab memory from ${userinfo.username} in ${shard}`);
return;
}
if (Object.keys(stats).length === 0) return;

console.log(`Got memory from ${userinfo.username} in ${shard}`);
Expand Down

0 comments on commit 12a2fc1

Please sign in to comment.