Respect Reddit rate limit delays
This commit is contained in:
1 parent
7bcdbe236a
commit
50de1c180d
5 files changed
+77
-10
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import type { RedditApiClient, RedditPost } from '../reddit/api.js';
|
||||
import { RedditRateLimitError, type RedditApiClient, type RedditPost } from '../reddit/api.js';
|
||||
import type { PostsRepository, MessagesRepository } from '../database/repositories.js';
|
||||
import type { Config } from '../config/index.js';
|
||||
import type { Logger } from '../utils/logger.js';
|
||||
@@ -92,7 +92,10 @@ export class MonitorService {
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
this.logger.error(`Failed to fetch posts from r/${subreddit.name}:`, error);
|
||||
if (error instanceof RedditRateLimitError) throw error;
|
||||
|
||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||
this.logger.error(`Failed to fetch posts from r/${subreddit.name}: ${errorMessage}`);
|
||||
}
|
||||
|
||||
// Small delay between subreddit fetches to be nice to Reddit
|
||||
|
||||
Reference in new issue
Block a user