Improve heartbeat resilience with consecutive failure tracking#37
Improve heartbeat resilience with consecutive failure tracking#37
Conversation
The Request library uses HttpClient with no timeout configured, so any network hiccup causes execute() to block indefinitely and eventually throw, which previously kicked all players on the very first failure. Two fixes applied to both velocity and waterfall Heartbeat: - Wrap req.execute() in a CompletableFuture with a 10s timeout so a slow/hung request fails fast rather than blocking forever - Track consecutive failures with AtomicInteger; only kick all players after 3 consecutive failures, not on the first transient error https://claude.ai/code/session_01SRyGmN3Re6fQsQDMxeL9Z3
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
BaseAPIURL and APIKey were declared twice — once in the outer method scope and again inside the lambda, causing a compilation error. Removed the redundant inner declarations; the lambda captures them from the outer scope. https://claude.ai/code/session_01SRyGmN3Re6fQsQDMxeL9Z3
The Velocity plugin was manually formatting and broadcasting chat to players, then calling ChatResult.denied() to suppress the default forward. However, SignedVelocity (a required dependency) intercepts signed chat packets at the network level and forwards them to the backend before Velocity's event result is evaluated, causing both the proxy-formatted message and the backend's chat plugin output to appear simultaneously. Reverted to the same approach used in the Waterfall version: let chat pass through to the backend normally, only deny when the filter blocks content. The backend's chat plugin handles formatting. https://claude.ai/code/session_01SRyGmN3Re6fQsQDMxeL9Z3
Summary
Enhanced the heartbeat monitoring system in both Velocity and Waterfall implementations to be more resilient by introducing consecutive failure tracking before disconnecting players. This prevents transient API failures from immediately disrupting the server.
Key Changes
AtomicIntegerto track consecutive heartbeat failures instead of immediately disconnecting on first failureMAX_CONSECUTIVE_FAILURES(3) andREQUEST_TIMEOUT_SECONDS(10) constants for easier tuningCompletableFuturewith explicit timeout to prevent indefinite hangskickAllPlayers()method to reduce code duplicationImplementation Details
https://claude.ai/code/session_01SRyGmN3Re6fQsQDMxeL9Z3