Repository navigation
fix(coroutines): count MinestomDispatcher delays in ticks - #27
Merged
Merged
Conversation
…pending on Delay defaults Implement every Delay member MinestomDispatcher relies on, so it no longer calls interface default bodies that only exist in some kotlinx.coroutines versions (withTimeout hung forever on 1.10.2). Delays and timeouts are scheduled in whole ticks, rounding up, resume without an extra tick hop, and release their continuation when cancelled. Scheduler.await is now cancellable, delayTicks is added, and tests run against the coroutines version the library compiles with.
…outines KotStom targets the kotlinx.coroutines version it compiles against.
…y and treat overflowing delays as infinite
…verflow and cancellation
oglassdev
marked this pull request as ready for review
October 15, 2026 00:44
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.
Summary
MinestomDispatcherdelays and timeouts now count whole ticks, rounding up (delay(50)= 1 tick,delay(30)= 1 tick,delayTicks(n)= exactly n ticks), and resume on the tick they fire without an extra dispatch hop.invokeOnTimeoutinstead of relying onDelay's default method. PreviouslywithTimeouton this dispatcher hung forever when the runtime coroutines version didn't match.withTimeouts and cancelledScheduler.awaits release their continuation immediately; Minestom keeps cancelled tasks queued until their tick.MAX_DELAY_TICKS(Int.MAX_VALUE / 2) never fire, instead of overflowing Minestom's int tick deadline and firing immediately.Scheduler.awaitis now cancellable.Verification
Known limitations (not addressed)
draindefault), and cancelled tasks count toward it. Under that load, delays and dispatches slip a tick. Fixing it would mean a KotStom-owned tick queue.MinestomDispatcher,delayTicksis a wall-clockticks * 50msdelay.MinestomDispatcherwork still deadlocks.