Skip to content

Commit

Permalink
feat(twitter): double lock time
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Nov 3, 2024
1 parent a9d2ea5 commit 0c506b8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/routes/twitter/api/web-api/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export const twitterGot = async (
const resetTime = new Date(Number.parseInt(reset) * 1000);
const delay = (resetTime.getTime() - Date.now()) / 1000;
logger.debug(`twitter debug: twitter rate limit exceeded for token ${auth.token} with status ${response.status}, will unlock after ${delay}s`);
await cache.set(`${lockPrefix}${auth.token}`, '1', Math.ceil(delay));
await cache.set(`${lockPrefix}${auth.token}`, '1', Math.ceil(delay) * 2);
} else if (response.status === 429 || JSON.stringify(response._data?.data) === '{"user":{}}') {
logger.debug(`twitter debug: twitter rate limit exceeded for token ${auth.token} with status ${response.status}`);
await cache.set(`${lockPrefix}${auth.token}`, '1', 2000);
Expand Down

0 comments on commit 0c506b8

Please sign in to comment.