The plain forwarder's truncated-UDP test passes on Windows, and a UDP reset from an upstream counts as a failed attempt #364

Closed
opened 2026-11-06 20:40:56 -05:00 by claude · 0 comments
Owner

Part of epic #8. Found by the manual run of the new test-windows job (#18) on Lofnheim, 2026-11-06.

  • Draft: none
  • Priority: high (the test-windows job goes red on its first push without it)
  • Agent: protocol-coder
  • Depends on: epic #8 part 2 (#17, BoundPort)
  • Decisions: none

Why

Ninlil.Dns.Server.Forwarding.ClientProtocols.Tests.PlainForwarderClientTests.ForwardAsync_WhenTheUdpAnswerIsTruncated_RetriesOverTcpAndGetsTheFullAnswer fails natively on Windows: 1 failed, 4 passed in the project. It throws SocketException: An existing connection was forcibly closed by the remote host from Socket.ReceiveFromAsync in PlainForwarderClient.ForwardUdpWithFreshSocketAsync (src/dotnet/src/Ninlil.Dns.Server.Forwarding/Clients/PlainForwarderClient.cs, called from about line 125). It passes on Linux.

  • Windows reports an ICMP port-unreachable for a UDP send as WSAECONNRESET on the next receive. So the forwarder's query most likely reached a loopback port with no UDP listener on it.
  • The test class takes TestPort from a free TCP port (GetFreePort, reserve and release) and binds both UdpDnsListener and TcpDnsListener to it. Possible causes: the UDP listener lost the port or was not yet bound when the first query went out. This is a hypothesis.

What changes

  • Reproduce on Lofnheim and confirm the cause.
  • Fix the test so both listeners are proven bound before the query. For example, bind UDP on port 0, read UdpDnsListener.BoundPort, then bind TCP on that number with a bounded retry, as DualStackClientAddressTests does in part 2.
  • Product check: on Linux a fresh unconnected UDP socket to an unreachable upstream waits for the timeout. On Windows it fails fast with a SocketException. Confirm the forwarding callers (failover between forwarders, the per-forwarder timeout, query-log outcome) treat that exception as a failed attempt, the same as a timeout, and do not surface it as an unhandled error. If they do not, fix that in a separate commit with a test.

Acceptance

  • The cause is shown on Windows.
  • Ninlil.Dns.Server.Forwarding.ClientProtocols.Tests passes 20 times in a row natively on Lofnheim and in the CI container on asgard.
  • The product check is answered, and fixed if needed.
  • Every item in Before you finish that applies is done.
Part of epic #8. Found by the manual run of the new `test-windows` job (#18) on Lofnheim, 2026-11-06. - **Draft:** none - **Priority:** high (the `test-windows` job goes red on its first push without it) - **Agent:** protocol-coder - **Depends on:** epic #8 part 2 (#17, `BoundPort`) - **Decisions:** none ### Why `Ninlil.Dns.Server.Forwarding.ClientProtocols.Tests.PlainForwarderClientTests.ForwardAsync_WhenTheUdpAnswerIsTruncated_RetriesOverTcpAndGetsTheFullAnswer` fails natively on Windows: 1 failed, 4 passed in the project. It throws `SocketException: An existing connection was forcibly closed by the remote host` from `Socket.ReceiveFromAsync` in `PlainForwarderClient.ForwardUdpWithFreshSocketAsync` (`src/dotnet/src/Ninlil.Dns.Server.Forwarding/Clients/PlainForwarderClient.cs`, called from about line 125). It passes on Linux. - Windows reports an ICMP port-unreachable for a UDP send as WSAECONNRESET on the next receive. So the forwarder's query most likely reached a loopback port with no UDP listener on it. - The test class takes `TestPort` from a free TCP port (`GetFreePort`, reserve and release) and binds both `UdpDnsListener` and `TcpDnsListener` to it. Possible causes: the UDP listener lost the port or was not yet bound when the first query went out. This is a hypothesis. ### What changes - Reproduce on Lofnheim and confirm the cause. - Fix the test so both listeners are proven bound before the query. For example, bind UDP on port 0, read `UdpDnsListener.BoundPort`, then bind TCP on that number with a bounded retry, as `DualStackClientAddressTests` does in part 2. - Product check: on Linux a fresh unconnected UDP socket to an unreachable upstream waits for the timeout. On Windows it fails fast with a `SocketException`. Confirm the forwarding callers (failover between forwarders, the per-forwarder timeout, query-log outcome) treat that exception as a failed attempt, the same as a timeout, and do not surface it as an unhandled error. If they do not, fix that in a separate commit with a test. ### Acceptance - [ ] The cause is shown on Windows. - [ ] `Ninlil.Dns.Server.Forwarding.ClientProtocols.Tests` passes 20 times in a row natively on Lofnheim and in the CI container on asgard. - [ ] The product check is answered, and fixed if needed. - [ ] Every item in [Before you finish](https://git.lantea.one/lantea-one/ninlil/src/branch/main/AGENTS.md#before-you-finish) that applies is done.
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#364
No description provided.