cats-effect
cats-effect copied to clipboard
`WorkerThread#blockOn` implementation note is incorrect
blockOn may be invoked by directly using the WSTP as an ExecutionContext with scala.concurrent.blocking, no IO involved. So that's not sufficient justification for not using try/catch. Not sure if we can rejustify it, or just have to add it in.
https://github.com/typelevel/cats-effect/blob/92186482cd779b5baec1db6cf4b88245264c8592/core/jvm/src/main/scala/cats/effect/unsafe/WorkerThread.scala#L923-L933
So I think the conclusion of the note is correct even though the reasoning isn't. You can't get into blockOn without being already on the thread pool, which means we're going to be wrapped in a top level try/catch.
The note in blockOn has incorrect reasoning. While try/catch may not be needed, the justification should be updated. Since calls always happen on the worker thread pool, exceptions are caught at the top level. Should we revise the note to reflect this? I can raise a PR.