This PR fixes a race condition where fetching the maximum datagram size limit occurred too soon (before reading from the TUN interface) causing the limit to be too old (and in some high-throughput cases, incorrect, due to congestion) when connection.send_datagram was called, which resulted in the datagram being rejected by the QUIC connection leading to an unrecoverable error.
By moving the fetch right before the size check and the connection.send_datagram, this error is now recoverable, as MTU path discovery updates the maximum MTU to a reasonable value after some time passes (from my testing about 15 seconds, depending on the 'length' of the connection).
This PR fixes a race condition where fetching the maximum datagram size limit occurred too soon (before reading from the TUN interface) causing the limit to be too old (and in some high-throughput cases, incorrect, due to congestion) when
connection.send_datagram
was called, which resulted in the datagram being rejected by the QUIC connection leading to an unrecoverable error.By moving the fetch right before the size check and the
connection.send_datagram
, this error is now recoverable, as MTU path discovery updates the maximum MTU to a reasonable value after some time passes (from my testing about 15 seconds, depending on the 'length' of the connection).