Skip to content

Octokit Rate Limit Suspension & Resume #23

Description

@SHAURYASANYAL3

🛑 The Problem

When syncing massive repositories, we will inevitably hit GitHub's API rate limit (5,000 requests per hour). When this happens, Octokit throws a 429 error. Currently, our Inngest worker crashes, marks the job as failed, and the user never gets their data.

💡 The Solution

We must catch the 429 Rate Limit error, extract the reset timestamp, and use Inngest's native step.sleepUntil() feature to suspend the worker cleanly until GitHub restores our quota.

🛠️ Implementation Details

  1. Wrap the Octokit fetch loop in a try/catch block.
  2. If the error status is 403 or 429 and includes the x-ratelimit-reset header, parse the Unix timestamp.
  3. Convert the timestamp to a JavaScript Date object.
  4. Call await step.sleepUntil('wait-for-rate-limit', resetDate).
  5. Once the sleep finishes, Inngest will automatically wake the worker back up and resume the loop.

✅ Acceptance Criteria

  • Rate limits do not cause the job to fail permanently.
  • The worker sleeps for the exact correct duration (not just a hardcoded 1 hour).
  • No database state is corrupted during the suspension.

Ready to tackle this? Comment .take below to get automatically assigned!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions