EssentialsX_Economy + PawEconomy = Server halt / Server crash
Tia-Paw opened this issue ยท 5 comments
Type of bug
Other unexpected behaviour
/ess dump all
output
https://github.com/Tia-Paw/errors-uploaded/blob/main/error-1.txt
Error log (if applicable)
https://github.com/Tia-Paw/errors-uploaded/blob/main/error-1.txt
Bug description
Using a plugin that's currency takes longer to transmit (PawEconomy/BananoCraft), halts the entire server due to EssentialsX using the main thread for the calculation.
Steps to reproduce
- Set up PaperMC server
- Add BananoCraft (I forked it, that's why I called it PawEconomy) plugin
- Add EssentialsX plugin
- Add Vault plugin
- Sell to the server with the "/sell hand" command
- Watch everything halt until the process is complete, or even crash
Expected behaviour
Server works normal while calculation is done.
Actual behaviour
Server become unresponsive while calculation is done, or crashes.
PawEconomy is making blocking HTTP requests on the main server thread. You will need to ask the author of that plugin to fix it, as this isn't something that Essentials can or would be able to fix.
Is there a reason why the sell function doesn't utilize this?:
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {}
I am still learning so I might be dense here, but it seems as if this could solve the issue.
No shame in being a beginner, basically: Essentials uses Vault, and the methods provided via that API are synchronous. If the task was to run asynchronously the entire API would need to be designed around that so that results can be passed appropriately. Also not everything is thread-safe (especially if it touches the Bukkit API). The solution is just to not do an HTTP request in your handling code, or handle it async somehow in a way that makes sense in the context of the Vault API.
Is there a reason why the sell function doesn't utilize this?:
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {}
I am still learning so I might be dense here, but it seems as if this could solve the issue.
Is there a reason why the sell function doesn't utilize this?:
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {}
I am still learning so I might be dense here, but it seems as if this could solve the issue.
It's not a safe operation to do async, economy plugins may modify gamestate. PawEconomy should be doing the HTTP request async.