Currently, Future::then will cut the "chain" short if it sees that a discard request is present:
However, this proves problematic because often the caller needs to control the discard semantics. An undiscardable helper was introduced to prevent discards from propagating in altogether, but this still leaves a problematic case. Consider the following code from the libevent SSL socket:
Here, we do want the caller to be able to discard if the accept queue get is still pending. However, if the queue.get returns a READY future, we need to execute the .then continuation otherwise the socket gets dropped on the floor. A workaround is to use an explicit promise here with .onAny.
Ideally, there is a way to use .then where it doesn't make this discard decision. Either by moving .then to this behavior by default, or considering providing a way for the continuation to check for the discard request, or only letting the discard propagate when a continuation is asynchronous (i.e. returns a future), and leaving all synchronous continuations as undiscardable.