The DNSCrypt forwarder tests' loopback relay stops cleanly on Windows when its receive is aborted #367

Closed
opened 2026-11-06 22:04:07 -05:00 by claude · 0 comments
Owner

Part of epic #8. Found by the first real run of test-windows (#18): develop push run 1310 at 595945de, the #365 merge.

  • Draft: none
  • Priority: high (develop is red)
  • Agent: protocol-coder
  • Depends on: none
  • Decisions: none

Why

Ninlil.Dns.Server.Forwarding.Tests.DnsCryptForwarderClientTests.ForwardAsync_PadsTheUdpQueryToAtLeast256Bytes (src/dotnet/tests/Ninlil.Dns.Server.Forwarding.Tests/DnsCryptForwarderClientTests.cs) failed on Windows. The project result was 1 failed, 257 passed, and the other 47 test projects passed:

System.Net.Sockets.SocketException : The I/O operation has been aborted because of either a thread exit or an application request.
   at ...DnsCryptForwarderClientTests.LoopbackRelay.UdpRepliesAsync(Socket fromUpstream, EndPoint client, Boolean injectGarbage, CancellationToken stoppingToken)
  • On Windows, closing a socket or cancelling its pending receive completes the receive with SocketException (OperationAborted, WSA_OPERATION_ABORTED), where Linux usually raises OperationCanceledException or ObjectDisposedException. The test's loopback relay apparently treats only the latter as a normal stop. So a teardown that races the relay's receive fails the test, even though the assertion under test passed.
  • The same project passed on Lofnheim in manual runs earlier on 2026-11-06, so it is intermittent. This is a hypothesis from the trace.

What changes

  • Confirm from the code. Make the relay treat OperationAborted (and Interrupted, if relevant) after its stop or cancellation as a normal end. Do not swallow aborts that happen before the stop.
  • Check the other loopback relays and fake servers in the Forwarding and ClientProtocols tests for the same pattern, and fix them the same way.
  • Check that no production receive loop has the same gap. Listeners and forwarder clients that stop by closing a socket must not log or fail on OperationAborted during shutdown on Windows. List what you checked.

Acceptance

  • Ninlil.Dns.Server.Forwarding.Tests passes 20 times in a row natively on Lofnheim and in the CI container on asgard.
  • The production check is answered, and fixed if needed.
  • test-windows is green on the develop push after the merge.
Part of epic #8. Found by the first real run of `test-windows` (#18): develop push run 1310 at 595945de, the #365 merge. - **Draft:** none - **Priority:** high (develop is red) - **Agent:** protocol-coder - **Depends on:** none - **Decisions:** none ### Why `Ninlil.Dns.Server.Forwarding.Tests.DnsCryptForwarderClientTests.ForwardAsync_PadsTheUdpQueryToAtLeast256Bytes` (`src/dotnet/tests/Ninlil.Dns.Server.Forwarding.Tests/DnsCryptForwarderClientTests.cs`) failed on Windows. The project result was 1 failed, 257 passed, and the other 47 test projects passed: ``` System.Net.Sockets.SocketException : The I/O operation has been aborted because of either a thread exit or an application request. at ...DnsCryptForwarderClientTests.LoopbackRelay.UdpRepliesAsync(Socket fromUpstream, EndPoint client, Boolean injectGarbage, CancellationToken stoppingToken) ``` - On Windows, closing a socket or cancelling its pending receive completes the receive with `SocketException` (`OperationAborted`, WSA_OPERATION_ABORTED), where Linux usually raises `OperationCanceledException` or `ObjectDisposedException`. The test's loopback relay apparently treats only the latter as a normal stop. So a teardown that races the relay's receive fails the test, even though the assertion under test passed. - The same project passed on Lofnheim in manual runs earlier on 2026-11-06, so it is intermittent. This is a hypothesis from the trace. ### What changes - Confirm from the code. Make the relay treat `OperationAborted` (and `Interrupted`, if relevant) after its stop or cancellation as a normal end. Do not swallow aborts that happen before the stop. - Check the other loopback relays and fake servers in the Forwarding and ClientProtocols tests for the same pattern, and fix them the same way. - Check that no production receive loop has the same gap. Listeners and forwarder clients that stop by closing a socket must not log or fail on `OperationAborted` during shutdown on Windows. List what you checked. ### Acceptance - [ ] `Ninlil.Dns.Server.Forwarding.Tests` passes 20 times in a row natively on Lofnheim and in the CI container on asgard. - [ ] The production check is answered, and fixed if needed. - [ ] `test-windows` is green on the develop push after the merge.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lantea-one/ninlil#367
No description provided.