fix(api): re-raise RateLimitError after exhausting retries#33
Open
guanbinrui wants to merge 1 commit into
Open
fix(api): re-raise RateLimitError after exhausting retries#33guanbinrui wants to merge 1 commit into
guanbinrui wants to merge 1 commit into
Conversation
The retry template swallowed the final RateLimitError instead of
propagating it. When every fetch attempt is rate limited (common on a
busy public instance with few sessions), the loop caught the last
exception, logged, slept, and fell through without re-raising. fetch then
returned its default nil JsonNode, which the parsers dereference.
Because the binary is built with -d:danger, that nil access is an
uncatchable SIGSEGV ("Attempt to read from nil") rather than a Nim
exception, so Jester's RateLimitError handler never runs. The process
dies and restart: unless-stopped loops it forever.
Re-raise on the final attempt so the error propagates to Jester's
RateLimitError handler (HTTP 429), matching upstream semantics. Also
guard against maxRetries <= 0 making the loop a no-op.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Nitter was stuck in a crash → restart → crash loop. Logs showed a SIGSEGV immediately after the server started serving:
…repeating on every restart (
restart: unless-stopped).Root cause
The
retrytemplate insrc/apiutils.nimswallowed the finalRateLimitErrorinstead of propagating it:On a busy public instance with few sessions, sessions get rate-limited within seconds, so every
fetchattempt raisesRateLimitError. The loop caught the last one, logged, slept, and fell through without re-raising.fetchthen returned its default nilJsonNode(e.g.getGraphUserTweets:js = await fetch(url)), and the parser dereferenced the nil JsonNode's backing tree.Because the binary is built with
-d:danger(Dockerfile), nil checks are off, so this is an uncatchable SIGSEGV rather than a Nim exception — Jester'serror RateLimitError/InternalErrorhandlers never run. The process dies and the restart policy loops it forever.Upstream Nitter avoids this by letting the final
RateLimitErrorpropagate so Jester returns an HTTP 429 page.Fix
Re-raise on the final attempt so the error reaches Jester's
RateLimitErrorhandler (HTTP 429), matching upstream semantics. Also guard againstmaxRetries <= 0making the loop a no-op.Result
🤖 Generated with Claude Code