Shynixn / MCCoroutine

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

Fix async coroutine exception event and gitignore #84

Closed Spliterash closed 2 years ago

Spliterash commented 2 years ago

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

Shynixn commented 2 years 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 2 years 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 2 years 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 2 years ago
plugin.scope.launch(asyncDispatcher) {
    throw RuntimeException("Exception in async dispatcher")
}
Shynixn commented 2 years ago

I have done some testing:

Thanks for your help.