Disable unavailable subreddits after Reddit 404

This commit is contained in:
jjbrunton committed 2026-08-08 22:53:24 +01:00
1 parent 664aa5c098
commit dcf57273e2
13 files changed
+153 -12

No files matched your search

+9 -2
View File
@@ -24,6 +24,14 @@ export class RedditAccessDeniedError extends Error {
}
}
/** Reddit confirms the community listing is gone and must no longer be polled. */
export class RedditSubredditUnavailableError extends Error {
constructor(public readonly subreddit: string) {
super(`Reddit reports that r/${subreddit} is unavailable (HTTP 404)`);
this.name = 'RedditSubredditUnavailableError';
}
}
function getRateLimitDelayMs(headers: unknown): number {
if (!headers || typeof headers !== 'object') return 60_000;
@@ -198,8 +206,7 @@ export class RedditApiClient {
} catch (error) {
if (axios.isAxiosError(error)) {
if (error.response?.status === 404) {
this.logger.warn(`Subreddit r/${subreddit} not found`);
return [];
throw new RedditSubredditUnavailableError(subreddit);
}
if (error.response?.status === 403) {
this.consecutiveListing403s += 1;