Skip to content

Treat EINVAL from TCP_NODELAY as a closed connection - #176

Merged
floitsch merged 1 commit into
mainfrom
macos-nodelay-einval
Oct 2, 2026
Merged

floitsch merged 1 commit into
mainfrom
macos-nodelay-einval

Conversation

@floitsch

@floitsch floitsch commented Oct 2, 2026

Copy link
Copy Markdown
Member

macOS rejects setsockopt with EINVAL once the peer has reset the connection. When this happened while sending request headers on a reused connection, the client saw Invalid argument, which is-close-exception_ doesn't recognize, so the request wasn't retried even with --retry-on-connection-close.

This made client-request-retry-test flaky on macOS (seen on #174: https://github.com/toitlang/pkg-http/actions/runs/37032094927/job/110921188938).

Both TCP_NODELAY changes in send-headers now go through a helper that reports this error as Connection closed. Other errors propagate unchanged, and the existing cleanup from #172 still closes the connection.

Not reproducible on Linux; the macOS CI run is the real check.

macOS rejects setsockopt with EINVAL once the peer has reset the
connection. When this happened while sending request headers on a
reused connection, the client saw "Invalid argument", which
is-close-exception_ doesn't recognize, so the request wasn't retried
even with --retry-on-connection-close. This made
client-request-retry-test flaky on macOS.

Route both TCP_NODELAY changes in send-headers through a helper that
reports this error as "Connection closed". The existing cleanup still
closes the connection.
@floitsch
floitsch merged commit f5a0eca into main Oct 2, 2026
13 checks passed
@floitsch
floitsch deleted the macos-nodelay-einval branch October 2, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant