Publishers and coroutines hanging issue

Hello all, I’m am running into a weird blocking issue with Micronaut 3 + kotlinx-coroutines-reactive with streaming file uploads. Here is the code: mn-multi-file-upload/TestController.kt at await-from-flux · rawilder/mn-multi-file-upload · GitHub

StreamingFileUpload is a Publisher from which I turn into a flux then await the result with one of the kotlinx-coroutines-reactive. What is weird, is that on the first request made to the application, it will hang on the await methods of kotlinx-coroutines-reactive. If I utilize reactor types only, I don’t seem to have the issue. Also it is inconsistent. If I enable trace logging for example, the first request will work sometimes. I assume that it has something to do with the timing of it all.

I’ve tried to debug but I just don’t have enough domain knowledge to know where to start looking (and trace logging keeps working so I can’t see where to look there). Has anyone encountered something similar with composing Publishers with coroutines?

I think I might’ve found the root cause. It looks like a dependent lib was cancelling an underlying subscriber and not propagating the cancellation/error which left the kotlin coroutines waiting for a termination signal that never came. This has happened in other scenarios too so I will update as I find more info.

2 Likes