Skip to content

macos: retry UDP sends during flow divert handoff - #328

Merged
mhils merged 2 commits into
mitmproxy:mainfrom
natefinch:macos-udp-send-retry
Sep 30, 2026
Merged

mhils merged 2 commits into
mitmproxy:mainfrom
natefinch:macos-udp-send-retry

Conversation

@natefinch

Copy link
Copy Markdown
Contributor

In macOS local mode, flow divert can briefly clear the connected state of mitmproxy's own outgoing UDP socket while handing it back to the regular UDP stack. send() then fails with EDESTADDRREQ/ENOTCONN and the UDP client task errors out.

This retries those two errors up to 10 times, 1 ms apart, before giving up. Other errors are unchanged. This is macOS-only. Adds tokio's time feature and a macOS libc dependency to mitmproxy-rs.

On macOS, local mode's flow divert can briefly clear the connected state of mitmproxy's
own outgoing UDP socket while handing it back to the regular UDP stack. `send()` then fails
with `EDESTADDRREQ` or `ENOTCONN` and the connection is torn down. Retry these errors a
bounded number of times before giving up.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0822dee1-89da-4338-994f-bf1a11052c0e
Comment thread mitmproxy-rs/src/udp_client.rs Outdated
Comment thread mitmproxy-rs/src/udp_client.rs Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0822dee1-89da-4338-994f-bf1a11052c0e

@mhils mhils left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for digging into this!

@mhils
mhils enabled auto-merge (squash) September 30, 2026 23:40
@mhils
mhils merged commit 5fa7523 into mitmproxy:main Sep 30, 2026
23 checks passed
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.

2 participants