Skip to content

Fix Discord blocking server startup during Cloudflare rate limits - #6618

Open
KeaneAudric777 wants to merge 1 commit into
EssentialsX:2.xfrom
KeaneAudric777:fix/discord-async-startup
Open

Fix Discord blocking server startup during Cloudflare rate limits#6618
KeaneAudric777 wants to merge 1 commit into
EssentialsX:2.xfrom
KeaneAudric777:fix/discord-async-startup

Conversation

@KeaneAudric777

Copy link
Copy Markdown
Contributor

Information

This PR fixes #6591.

Details

Proposed fix:
Passes startupAsync() through ess.runTaskAsynchronously in EssentialsDiscord.java rather than executing JDA login synchronously on the main thread during plugin enablement.

Previously, when JDA encountered connection timeouts or Cloudflare HTTP 429 rate limits, the blocking retry delay stalled the main server thread, hanging startup indefinitely. Offloading the initialization to an asynchronous task allows the server to complete its boot sequence immediately while Discord logs in and handles rate-limit retries in the background. Once JDA connects, interaction registrations are scheduled back onto the main thread via ess.scheduleSyncDelayedTask().

Environments tested:

OS: Windows 11
Java version: Java 21

  • Most recent Paper version (26.2)
  • CraftBukkit/Spigot/Paper 1.12.2
  • CraftBukkit 1.8.8

Demonstration:

  • Before: Server startup hanged during enablement at [EssentialsDiscord] Attempting to login to Discord... followed by JDA's Encountered cloudflare rate limit! Retry-After: ... on the main thread, blocking the server from finishing initialization.
  • After: Server completed initialization immediately (Done (...)! For help, type "help"), with the rate-limit delay and subsequent Discord login handled gracefully in the background without affecting the tick loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EssentialsXDiscord blocking up server startup when CloudFlare limit is hit

1 participant