Trouble with asymmetric backpressure?

i need to implement some sort of “long poll” functionality for a publicly-accessible web service. due to some amply-discussed issues with actor reentrancy, it is necessary to serialize all operations related to long polling with some sort of AsyncStream.

long polling is a special problem from a security standpoint, because the backpressure behavior needs to be different depending on the type of event.

  • for externally-generated events, there needs to be some sort of backpressure or request dropping policy. otherwise this interface is an obvious vulnerability.

  • internally-generated events should never be dropped. otherwise critical invariants (leaked promises, inconsistent state, etc.) will be violated.

i am not sure how to begin implementing this in a secure way. AsyncStream is a tempting shortcut, but it cannot be connected directly to an external interface in a safe manner. any advice?

1 Like