Where does Cats Effect cancelation become practically unavoidable? I feel like I never really need to think about it.
Timeouts are the easiest practical example to think about. If you contemplate that whole chain, from request handling in the server layer through the fiber which processes that request, making new requests to upstream services, waiting on those results, etc… there's a lot of timeouts involved in that. Any time you have a timeout, you need to recursively cancel everything which rolls up under it, and you need that cancelation to have a few properties:
- It must be irreversible (if you have a timeout, you can't un-timeout; this also implies a degree of determinism)
- It must be respected promptly
- It must backpressure control flow (ensuring that the continuation is not yielded until all finalizers have completed, implying constituent resources are released)
- It must not create invalid states (use after free) or leaks (related to backpressure)
Some of these are actually in mutual confl