mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-11 00:37:41 +00:00
A relay sends its matching events before its EOSE, so both an event and the relay's completion can sit buffered in their channels at the same time. The select() over the two channels picks a ready clause at random, so it could process the doneChannel completion first, empty `remaining`, and exit the loop while the matching event was still unread — returning null instead of the event. On a relay completion, drain the event channel first and treat any already-buffered event as the result before marking the relay done.