According to the documentation, flatMap chains are not cancellable. The comment of cancelBoundary also hints at this. However, the implementation seems to auto-cancel, see here and here. Is the documentation/comment outdated, or am I misunderstanding the implementation?
The docs are outdated :)
Ok, thanks. Does that mean that cancelBoundary is a no-op now? (Or does it make an async boundary?)
cancelBoundary has not changed, it introduces what we call a lightweight async boundary, i.e. it does not submit to a thread pool, but only to a trampoline. Given that it's still an Async node, it can be canceled (this is all independent of the cancelable flatMap thing)
I think we fixed the docs (the link in OP directs to the version https://github.com/typelevel/cats-effect/blame/eed64fa38d03dadba3c8cb55f18c82e9e98828b6/site/src/main/tut/datatypes/io.md#L368) - they now say
We should also note that flatMap chains are only cancelable only if the chain happens after an asynchronous boundary. After an asynchronous boundary, cancellation checks are performed on every N flatMap. The value of N is hardcoded to 512.
Most helpful comment
The docs are outdated :)