Fix fatal error propagation in async operations
Description
Fixes #4505
Fixed fatal error propagation in async operations so fatal errors crash the JVM instead of being caught and wrapped.
Changes
kernel/jvm/src/main/scala/cats/effect/kernel/AsyncPlatform.scala: Added fatal error detection in fromCompletableFuture to re-throw fatal errors instead of wrapping them
core/shared/src/main/scala/cats/effect/IO.scala: Removed IO.delay() wrapper in IO.async_ to allow fatal errors to propagate during callback registration
Why both changes?
fromCompletableFutureusesCompletableFuture.handle()which catches all exceptions, including fatal onesasync_hadIO.delay()wrapper catching fatal errors during callback registration
Testing
- Added tests for both
fromCompletableFutureandasync_fatal error scenarios - All tests pass (JVM tests, kernel tests)
- Eliminates need for
.onError(_ => IO.unit)workaround mentioned in the issue
Hi @armanbilge, @durban
Would you mind taking a look at this when you have a moment?
Thanks!
Since this is a bug fix, you can target the series/3.6.x branch
Thanks for the review and guidance. Just learnt about all these upstream branches now :blush:
Hello @armanbilge I guess i will have to wait for this PR t be merged and then I can proceed.. Thank you
@najuna-brian https://github.com/typelevel/cats-effect/pull/4518 is merged now, thanks for your patience! You can merge the latest series/3.6.x into your branch.
@najuna-brian it looks like one of the tests you added is hanging in the CI. Are you able to run the tests locally?
Yes true they keep hanging, Though I am not sure of how to solve that.
@najuna-brian #4518 is merged now, thanks for your patience! You can merge the latest
series/3.6.xinto your branch.
Thank you @armanbilge I will please proceed now
Yes true they keep hanging, Though I am not sure of how to solve that.
You should start by identifying which test is hanging (a low-tech way to do this is to comment out tests until you figure out which one it is). Then, once you know which test it is, you can try reverting some of your changes to identify which change you made may cause it to hang.