Skip to content

server/router/build: remove wrapOutputBufferedUntilRequestRead workaround if possible #51209

Closed

Description

@thaJeztah

Description

relates to:

The commits above added a wrapOutputBufferedUntilRequestRead utility to work around an issue in go;

Those issues are closed, mentioning that go1.21 now has support for full-duplex HTTP/1 responses;

Use Response controller.EnableFullDuplex if you need to write before reading the full body.

We should look if we can remove that workaround and use what's recommended by the Go maintainers.

if body != nil {
// there is a possibility that output is written before request body
// has been fully read so we need to protect against it.
// this can be removed when
// https://github.com/golang/go/issues/15527
// https://github.com/golang/go/issues/22209
// has been fixed
body, ww = wrapOutputBufferedUntilRequestRead(body, ww)
}

Activity

  1. jasonoh11 commented on Nov 11, 2025

    @jasonoh11

    Hello, I'm interested in contributing and would like to work on this feature if it's available.

    My classmate Ian Kim and I are CS students at the University of Texas, currently taking a virtualization course that includes an open-source contribution component.

    We proposed this issue to our professor, and he approved it as a suitable contribution. Could you confirm whether this is something the team is interested in moving forward with? If so, could it be assigned to me?

    Thanks!

  2. thaJeztah commented on Nov 11, 2025

    @thaJeztah
    MemberAuthor

    Yes, contributions welcome; big disclaimer though that the main work will be to verify if the code is still needed. I started to dig a bit in git history to try and find if there were good reproducers that could help verify if it's still needed (or redundant now / replaceable with alternatives), but didn't have time to fully dig in, hence why I opened a ticket as a reminder to look into it ☺️😅

  3. jasonoh11 commented on Nov 18, 2025

    @jasonoh11

    We've looked into this a bit and have begun experimenting a bit with EnableFullDuplex() in local environments. We also drafted a potential alternative to wrapOutputBufferedUntilRead() using EnableFullDuplex(). Here's a snippet:

    	if r.Body != nil {
    		rc := http.NewResponseController(w)
    		if err := rc.EnableFullDuplex(); err != nil {
    			log.G(ctx).WithError(err).Debug("failed to enable full-duplex, response may be buffered")
    		}
    	}
    

    From what we understand, most of the work here will be testing and validating whether an implementation like this is actually correct. Our plan is to first reproduce the original behavior that the workaround was meant to fix, so we can confirm that the new approach resolves it. Does that seem like the right direction to take? And do you have any suggestions or references that could help us better understand the specific issue the workaround was originally added for?

  4. jasonoh11 commented on Nov 24, 2025

    @jasonoh11

    Hi, any updates/thoughts/tips on our plan?

  5. added 2 commits that reference this issue on Apr 15, 2026
    639cdd0
    4952040
  6. added a commit that references this issue on May 6, 2026
    70ac493
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions