Shynixn / MCCoroutine

MCCoroutine is a library, which adds extensive support for Kotlin Coroutines for Minecraft Server environments.
Other
210 stars 19 forks source link

Fix async coroutine exception event and gitignore #84

Closed Spliterash closed 1 year ago

Spliterash commented 1 year ago

When plugin use asyncEventDispatcher in coroutines, and inside coroutines drop exception, bukkit crash, because exception throws not in main thread image

Shynixn commented 1 year ago

Hello, thank you for reporting and fixing this. This problem was probably introduced in 2.6.0 by moving from standard event to plugin event. It may even be better to revert the 2.6.0 change in MCCoroutine. However, I may need some days until I can work on it.

Spliterash commented 1 year ago

@Shynixn No it's not that. It's just that bukkit requires you to explicitly specify what type of event (synchronous or asynchronous), and PluginEvent does not have the right constructor where you can pass this parameter

Shynixn commented 1 year ago

I see but there may be more to that. The MCCoroutine docs explicitly state how the MCCoroutineException event is always going to arrive on the primary thread. https://shynixn.github.io/MCCoroutine/wiki/site/exception/ That's the way I have designed it and according to your error something is not right.

Can you please send a short code snippet to trigger that error?

Spliterash commented 1 year ago
plugin.scope.launch(asyncDispatcher) {
    throw RuntimeException("Exception in async dispatcher")
}
Shynixn commented 1 year ago

I have done some testing:

Thanks for your help.