Skip to content

Serialize Velocity command dispatch - #161

Open
MachoPiggies wants to merge 2 commits into
tebexio:2.4.0-devfrom
MachoPiggies:fix/asynchronous-velocity-commands
Open

Serialize Velocity command dispatch#161
MachoPiggies wants to merge 2 commits into
tebexio:2.4.0-devfrom
MachoPiggies:fix/asynchronous-velocity-commands

Conversation

@MachoPiggies

Copy link
Copy Markdown

Fixes #160

Summary

This change serializes command dispatches on the Velocity platform by chaining the CompletableFuture returned from CommandManager#executeAsync.

Previously, dispatchCommand invoked executeAsync(...) and immediately returned, allowing multiple Tebex commands to execute concurrently. This could result in later commands completing before earlier ones, depending on their execution time.

By adding an internal CompletableFuture chain, each command waits for the previous command to complete before execution begins, whilst still preserving the dispatchCommand API.

This resolves a race condition where multiple Tebex commands dispatched in quick succession (for example, purchase followed immediately by remove during test payments) could complete out of order. The implementation is intentionally minimal and only affects the Velocity platform.

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.

Race commands on Velocity

1 participant