cats-effect icon indicating copy to clipboard operation
cats-effect copied to clipboard

`WorkerThread#blockOn` implementation note is incorrect

Open armanbilge opened this issue 11 months ago • 2 comments
trafficstars

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

armanbilge avatar Dec 06 '24 23:12 armanbilge

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.

djspiewak avatar Dec 08 '24 15:12 djspiewak

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.

PraverBajaj avatar Mar 12 '25 21:03 PraverBajaj