typelevel / typelevel/cats-mtl

Handle.allow(F) and (Applicative|Monad)Throw appear to be incompatible.

Open
#652 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
307
Forks
66
Avg merge
6h 23m
Merged PRs (30d)
2

Description

Related to #645 and #648, it appears that code which uses MonadThrow and ApplicativeThrow (or their equivalent *Errors) for generic error handling cannot safely be composed with Handle.allow(F).

The issue appears to be that Handle.Submarine does not extend ControlThrowable so it's not filtered out by NonFatal and it'll be caught by any of the adapt or recover methods that handle errors generically instead of enumerating a subset of error types.

Here's a gist with an example of how a simple generic retry helper could produce this behavior: https://gist.github.com/morgen-peschke/c3c65a25bae244e4a1c6e83a387b661c

Output is:

$ scala-cli run Example.scala 
Compiling project (Scala 2.13.15, JVM (21))
Compiled project (Scala 2.13.15, JVM (21))
============ Expecting OutOfRetries with nested OperationFailures ============
Retries exceeded after 2 attempts:
  cats.mtl.Handle$Submarine
  cats.mtl.Handle$Submarine

It's not visible in the output, but the expected OperationFailure instances are nested inside the Submarine instances.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Handle.Submarine and reproduce the behavior using the linked gist. Trace how generic MonadThrow and ApplicativeThrow adapt or recover methods interact with NonFatal, then compare the observed retry output with the expected nested OperationFailure behavior. Done means the incompatibility is resolved without losing the stated generic error-handling behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.