MatrixAI / js-quic

QUIC Networking for TypeScript & JavaScript
https://matrixai.github.io/js-quic/
Apache License 2.0
13 stars 1 forks source link

Server should abort starting connections when stopping with `force: true` #102

Closed tegefaulkes closed 3 months ago

tegefaulkes commented 3 months ago

Specification

While investigating discovery tests in Polykey I found that they consistently took 20 seconds to complete. Digging deeper I found that the test was very quick, but stopping the QUICServer was taking about 17 seconds.

It turns out that in the case where the server has starting connection and we call quicServer.stop({force: true}) it will wait for the connection to time out rather that force it to stop. While stopping the server is calling connection.stop({ force: true}) but in this case the following happens.

  1. The connection is starting holding the lifecycle lock.
  2. connection.stop is called but since the connection is in a starting state it's awaiting the lock.
  3. The connection times out entering a stopped state without entering the started state at any point.
  4. stop gets the lock but resolves as a NOP operation since its not currently waiting.

So the main problem here is that we don't abort any starting connections when stopping the server. So we need to send an abort to any starting connections in this case.

Additional context

Tasks

  1. Create a test demonstrating the condition involved.
  2. Implement a method to send an abort signal with a server stopping symbol to any starting connections. This could just be a top level abort signal and controller for the whole QUICServer.
linear[bot] commented 3 months ago

ENG-328 Server should abort starting connections when stopping with `force: true`