Skip to content

fix(netwatch): ignore transient recv errors#166

Merged
Frando merged 3 commits into
mainfrom
Frando/ignore-transient-error
Jun 16, 2026
Merged

fix(netwatch): ignore transient recv errors#166
Frando merged 3 commits into
mainfrom
Frando/ignore-transient-error

Conversation

@Frando

@Frando Frando commented Jun 16, 2026

Copy link
Copy Markdown
Member

Description

On Windows, UdpSocket::recv can return an error if the previous send operation on that socket failed with an ICMP error.

The error either surfaces as WSAECONNRESET, which the Rust standard library converts into a io::ErrorKind::ConnectionReset, or as a WSAENETRESET, which becomes ErrorKind::Uncategorized.

WSAECONNRESET is emitted if the previous send failed due to a ICMP port unreachable, and WSAENETRESET if the previous send got a TTL expired (I think, not sure exactly).

Both of these errors are transient, because they are issued max. once per sent datagram. The next recv on the socket then returns either a datagram, a different error, or WouldBlock.

This PR changes the behavior such that we ignore these errors.

It comes with a regression test (first commit). I confirmed that it fails on windows without the fix in the second commit.

Fixes n0-computer/iroh#4297
Fixes n0-computer/iroh-gossip#149
Also tested in n0-computer/iroh#4348

Breaking Changes

None

Notes & open questions

We can and likely should set the SIO_UDP_CONNRESET socket option on the underlying socket, which supresses at least the WSAECONNRESET error altogether. This would need to happen in noq_udp though. And even if we did it, it's still better to also ignore these errors here IMO.

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • All breaking changes documented.

@Frando Frando changed the title fix: ignore transient recv errors fix(netwatch): ignore transient recv errors Jun 16, 2026
@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/net-tools/pr/166/docs/net_tools/

Last updated: 2026-06-16T10:10:30Z

@flub

flub commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

very nice

We can and likely should set the SIO_UDP_CONNRESET socket option on the underlying socket, which supresses at least the WSAECONNRESET error altogether. This would need to happen in noq_udp though. And even if we did it, it's still better to also ignore these errors here IMO.

Yes to setting this socket option. There's no point in wasting the syscalls to read this.

@Frando Frando merged commit 8b2d36b into main Jun 16, 2026
29 checks passed
@matheus23 matheus23 deleted the Frando/ignore-transient-error branch June 18, 2026 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IpTransport should ignore WSAENETRESET errors on recv

2 participants