typelevel / fs2

Compositional, streaming I/O library for Scala
https://fs2.io
Other
2.38k stars 603 forks source link

Fix Ordering of UDP pending timeouts #3434

Closed zkerriga closed 6 months ago

zkerriga commented 6 months ago

Current Ordering.by[Timeout, Long](_.expiry) in AsynchronousSocketGroup is built the way so pendingTimeouts: PriorityQueue[Timeout] returns not the closest timeout that can be expired, but the furthest one during .headOption calls in selectorThread. Which, when read/write is called frequently, causes the selectorThread at each iteration to check for a timeout that was just added and does not need to be removed from the queue, causing a memory leak due to the infinite growth of pendingTimeouts.

I have checked locally that when using reverse, pendingTimeouts.headOption returns a timeout with the closest expiry time.

Unfortunately, I couldn't figure out a test for it

zkerriga commented 6 months ago

I'm new here, the pipeline issues are not obvious to me. @mpilquist, could you please help and also review?

armanbilge commented 6 months ago

My guess is that CI is failing because it's silently updated to a newer version of Node.js than is supported by the old Scala.js in the build. We should open a separate PR to try and update the build / CI to be operational again.