Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

fix(reddit): retry the submit after a RATELIMIT rejection instead of failing

Gilad Resisi6fb5df417eb8
diff --git a/libraries/nestjs-libraries/src/integrations/social/reddit.provider.ts b/libraries/nestjs-libraries/src/integrations/social/reddit.provider.ts
index 201f00769..a1a6c219d 100644
--- a/libraries/nestjs-libraries/src/integrations/social/reddit.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/reddit.provider.ts
@@ -520,6 +520,14 @@ export class RedditProvider extends SocialAbstract implements SocialProvider {
// Reddit rejects submissions with a 200 and an errors array: surface the
// real reason instead of failing later with an unknown outcome.
if (all?.json?.errors?.length) {
+ // A rate limit is a refusal, nothing was submitted: disarm the marker so
+ // the next check re-arms this subreddit and submits it again once the
+ // window has passed, instead of failing the whole post.
+ if (all.json.errors.some((e: any[]) => e?.[0] === 'RATELIMIT')) {
+ data.armed = undefined;
+ return { status: 'pending', pendingData: data };
+ }
+
throw new BadBody(
this.identifier,
JSON.stringify(all),