MadelineProto
MadelineProto copied to clipboard
Delay logic broken by parallel batching in InternalState
The startBroadcast method currently batches requests in groups of 50 using await($promises). However, the delay($this->delay) call is located inside the async closure.
https://github.com/danog/MadelineProto/blob/5b0d9d3691dd07e6d9e2ec7ceba79edf767874eb/src/Broadcast/InternalState.php#L189
When the loop executes, 50 async tasks are scheduled almost immediately. If $this->delay is set (e.g., 5 seconds), all 50 tasks sleep concurrently and then wake up at the exact same time to send their messages.