Skip to content

fix: report buffered progress when message writes fail - #1033

Open
tianrking wants to merge 1 commit into
gorilla:mainfrom
tianrking:codex/writer-progress
Open

tianrking wants to merge 1 commit into
gorilla:mainfrom
tianrking:codex/writer-progress

Conversation

@tianrking

@tianrking tianrking commented Oct 4, 2026 •

Copy link
Copy Markdown

What type of PR is this?

  • Bug Fix

Description

messageWriter.Write and WriteString currently return (0, err) if a later buffer flush fails, even when the current call has already copied a prefix into the message buffer and an earlier frame has reached the peer. This also makes io.Copy report zero progress for that call.

Return nn - len(p) on the buffered-loop error path, so the count reflects bytes accepted from the current argument. Bytes pending from an earlier call are not included. The returned count describes buffer acceptance; it does not guarantee that every counted byte reached the peer. Error identity, sticky failure behavior, successful writes, and the existing large-server fast path are unchanged.

Add a regression matrix using actual HTTP Upgrade/Dial and TCP client/server sockets, with a deterministic write-error wrapper after the first successful write. It covers Write, WriteString, io.Copy, primed-buffer/current-call accounting, separate peer-delivery assertions, zero progress, sticky errors, success, and the large-server fast path. Every socket has bounded deadlines and cleanup.

Related Tickets & Documents

The original-source run reproduces the count error: original RED, unchanged production blob 9562ffd4978ccabea0da2f06256e1c281bcefb7f. Five existing controls passed; twelve new progress cases failed (0 rather than 16/13), while all fourteen boundary/control cases passed. The same regression source is used in this PR.

Existing proxy-test instability is tracked separately in #982; no proxy-test change is included here.

Added/updated tests?

  • Yes

Run verifications and test

An isolated public-fork Ubuntu workflow explicitly checked out exact source commit 97f927d22d5982ce81101efe76adac24bf59fd78 (native validation). The workflow commit differs from the source commit and is excluded from this PR.

  • Go 1.20.14, 1.21.13, 1.22.12 and 1.27.1: all 26 new socket regressions, existing focused controls, complete go test -v -race -coverprofile=... ./..., go vet ./... and formatting of both changed files passed. The full run has 77 passing top-level tests and 30 passing subtests; no race warnings or skips.

  • Go 1.22: all 20 existing benchmark cases executed with -benchtime=1x -benchmem. This is a smoke check, not a performance claim.

  • Both changed-file Git blobs/SHA256 and actual source HEAD were verified before and after all commands, with zero tracked diff. Both writer methods have 100% statement coverage in this run.

  • Full original/fixed race suites were paired. Earlier attempts encountered existing proxy-test flakes, and the final Go 1.27 baseline also failed an existing proxy test while the fixed full run passed. These failures are retained; this PR does not claim to repair the proxy flake.

  • Whole-project Go 1.27 formatting fails on both original and fixed sources with the same 6127-byte doc.go diff (comparison exit 0). The changed files pass gofmt.

  • Org-guide tools were run against original and exact fixed source without suppressions: golint and govulncheck exit 0 on both. Govulncheck reports unreachable dependency advisories, so this is not a claim of no advisories. Gosec exits 1 with the same 55 diagnostics on both. Golangci-lint exits 1 on both; with diagnostic limits removed, all 124 diagnostics are identical, and none concern the new test or modified returns.

  • make verify is passing

  • make test is passing

This repository has no Makefile or those targets. Both commands were attempted on original and fixed sources and returned exit 2; the equivalent project-native tests and quality commands are reported above. The aggregate helper workflow correctly remains FAILURE because it preserves those existing format/tool failures rather than claiming all checks green.

This change was developed with AI assistance and verified with the project's native commands.

The org-template reviewer-team request for gorilla/pull-request-reviewers was attempted, but GitHub rejected RequestReviewsByLogin because this account lacks permission. No reviewer-team assignment is claimed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant