Skip to content
This repository was archived by the owner on May 21, 2026. It is now read-only.

fix: Rate limit timer was never created due to inverted logic#488

Open
rmdes wants to merge 7 commits into
milanmdev:mainfrom
rmdes:fix/rate-limit-timer
Open

fix: Rate limit timer was never created due to inverted logic#488
rmdes wants to merge 7 commits into
milanmdev:mainfrom
rmdes:fix/rate-limit-timer

Conversation

@rmdes
Copy link
Copy Markdown

@rmdes rmdes commented Jan 11, 2026

Bug

The rate limit timer was never being created due to inverted logic in createLimitTimer():

// Before (broken)
if (!rateLimited) return;  // rateLimited is false, so !false = true, always returns!
rateLimited = true;        // Never reached

Impact

When hitting Bluesky's rate limit, the queue would:

  • Log "Post rate limit exceeded - process will resume after 30 seconds"
  • But the timer was never created
  • Queue kept retrying every runInterval (60s) instead of respecting the rate limit
  • This caused repeated failed attempts and wasted API calls

Fix

  // After (fixed)
  if (rateLimited) return;  // If already rate limited, don't create duplicate timer
  rateLimited = true;       // Now correctly sets the flag

Testing

Observed in production logs where a queue with 2791 items kept hitting rate limits every 60 seconds indefinitely, instead of properly backing off.

rmdes and others added 7 commits January 11, 2026 17:49
 reamaining 1 Including the just-posted item in the calculation ensures the spacing window accounts for all posts in the sequence, which is especially important for small queues where the difference between dividing by 2 versus 3 significantly affects the delay.
  Some websites return og:url values like 'https//example.com' (missing
  colon after protocol). These get treated as relative URLs and
  concatenated with the base URL, creating broken links.

  This fix:
  - Adds fixMalformedUrl() to correct 'https//' -> 'https://'
  - Improves URL validation regex to require proper protocol
  - Validates the corrected URL before using it
  created because rateLimited starts as false. This meant rate limits
  were never properly respected - the queue would keep retrying every
  runInterval instead of waiting for the rate limit to expire.

  Fixed by inverting the condition to `if (rateLimited) return` which
  correctly prevents duplicate timers while allowing the first timer to
  be created.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant