Skip to content

Protect TCP_NODELAY changes while sending headers - #172

Merged
floitsch merged 4 commits into
mainfrom
fix-send-headers-nodelay
Aug 19, 2026
Merged

Protect TCP_NODELAY changes while sending headers#172
floitsch merged 4 commits into
mainfrom
fix-send-headers-nodelay

Conversation

@floitsch

@floitsch floitsch commented Aug 19, 2026

Copy link
Copy Markdown
Member

A peer disconnect can let the terminating header write succeed but make the following TCP_NODELAY restoration throw. In that case send-headers exits before returning the body writer, leaving Connection.current-writer_ set while ResponseWriter.body-writer_ is null. Later cleanup then fails with Previous request not completed.

Keep the TCP_NODELAY disable inside the guarded header-send sequence and restore TCP_NODELAY in finally after the complete header is written. A nested success flag closes and resets the connection if restoration itself throws without masking a header-write failure.

The regression test now checks specifically for Previous request not completed. Other close traces vary by OS and SDK, including an intermittent SDK-level Success read error, and are outside this regression.

Fixes the failure in https://github.com/toitlang/pkg-http/actions/runs/32307179434/job/96242345996

Validation:

  • Toit analysis with warnings as errors
  • Focused regression repeated 50 times
  • 12/12 local non-external tests

@floitsch
floitsch merged commit 9edcd6a into main Aug 19, 2026
7 checks passed
@floitsch
floitsch deleted the fix-send-headers-nodelay branch August 19, 2026 22:25
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