fix(discord): avoid poisoning shared rate-limit buckets - #88666
Open
alexskatell wants to merge 1 commit into
Open
fix(discord): avoid poisoning shared rate-limit buckets#88666alexskatell wants to merge 1 commit into
alexskatell wants to merge 1 commit into
Conversation
Contributor
Reviewed by reviewer-e (AI automated review). Right call on the shared-state hazard: temporarily lowering |
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.
What does this PR do?
Discord route buckets can inherit a temporary 30-second rate-limit ceiling during post-connect slash-command synchronization. A production thread request later received
retry_after=136.57; discord.py raisedRateLimitedinstead of waiting, and Hermes entered its seed-message fallback, posted two duplicate notices, then abandoned the request.HTTPClient.max_ratelimit_timeoutis shared mutable state. Discord.py copies it into each route bucket when the bucket is created, so restoring the client property does not repair a thread bucket created during the synchronization window.This PR removes that shared mutation. Slash-command synchronization remains bounded by the existing 600-second
asyncio.wait_for(), while unrelated Discord routes keep the client's normal rate-limit policy.The tradeoff is that command synchronization can wait inside discord.py instead of surfacing and persisting an exact
retry_afterimmediately. The existing operation timeout still caps the wait, and avoiding cross-route state corruption is the safer boundary.Related Issue
Fixes #88653
PR #76060 handles residual 429 responses inside auto-thread creation. It does not remove the slash-sync mutation that caused the observed thread bucket to retain a 30-second ceiling. This PR stays separate from that function so the two changes do not conflict.
Type of Change
Changes Made
plugins/platforms/discord/adapter.pymax_ratelimit_timeoutduring post-connect command synchronization.tests/gateway/test_discord_connect.pyHow to Test
origin/main. It fails because synchronization exposes30.0instead of the configuredNone.1 passed.scripts/run_tests.sh tests/gateway/test_discord*.py -q:251 passed, 1 skipped, 0 failed.py_compileon the two changed files andgit diff --check: clean.scripts/run_tests.sh tests/ -qwith the exact CI dependency set:34,352 passed, 343 skipped, 20 failedacross 15 unrelated files on macOS. Replaying those 15 files against parentcf7b3d0c90fails the same 15 files; neither changed file fails.tests/tui_gateway/test_slash_worker_mcp_discovery.py; the single allowed rerun fails the same unrelated test. Windows, macOS-only, lint, security, and the other Linux slices pass.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings): inline rationale updated; other docs N/Acli-config.yaml.exampleif I added/changed config keys: N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows: N/AScreenshots / Logs
Production evidence: