async-http icon indicating copy to clipboard operation
async-http copied to clipboard

Requests hanging after previous request.body.read doesn't close

Open dishcandanty opened this issue 6 days ago • 2 comments

Quick Overview

Previous comment / where this is coming from: https://github.com/socketry/async-http/issues/183#issuecomment-3649099854

I'm experiencing an issue where the body read doesn't seem to close, causing the next request to hang. I suspect its due to a malformed request / bad headers / unusual client.

  • Async::HTTP::Server
  • request.body.read doesn't seem to close
  • request.body.close after request processing solves the issue
  • DragonRuby HTTP Client

Reproduce

I've created a minimal reproduce here with more example/data in the readme code https://github.com/dishcandanty/server-async-hang-reproduce

Overly simplifying:

  1. Send request
  2. Send second request (hangs on body read)

If the body.close is called, no issue. if the body.read is removed entirely, similarly no issues.

The "http client" where I'm reproducing the hang (haven't been able to reproduce with vanilla curl) is within DragonRuby, specifically using the http_post_body helpers

I haven't been able to reproduce this with vanilla curl even trying to replicate all the request data / headers. Ultimately though, I think its probably a bad thing that some malformed request can indefinitely hold open the server (malicious actors or silly devs doing weird things :D )

dishcandanty avatar Dec 13 '25 21:12 dishcandanty