You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NoMethodError: undefined method 'write_frame' for nil when reading an HTTP/2 response body after a graceful GOAWAY #254
After a graceful GOAWAY, the client connection closes once the last stream ends, even if the application hasn't read that stream's body yet. Reading the buffered body then fails in Input#read.
We see this in production on GET requests to sheets.googleapis.com through async-http-faraday with persistent clients. In the reproduction below, a 6 MB body fails and a 1 MB body reads fine.
Reproduction
require"async"require"async/http"require"async/http/protocol/http2"require"protocol/http/body/writable"require"socket"BODY_SIZE=Integer(ENV.fetch("BODY_SIZE",6_000_000))CHUNK="x" * 100_000Syncdo |task|
client_io,server_io=Socket.pair(:UNIX,:STREAM)task.asyncdoserver=Async::HTTP::Protocol::HTTP2.server(server_io)server.eachdobody=Protocol::HTTP::Body::Writable.newtask.asyncdo(BODY_SIZE / CHUNK.bytesize).times{body.write(CHUNK)}# Graceful GOAWAY that still lets stream 1 finish, sent raw so the server keeps serving it.goaway=Protocol::HTTP2::GoawayFrame.newgoaway.pack(1,Protocol::HTTP2::Error::NO_ERROR,"")server.write_frame(goaway)body.close_writeendProtocol::HTTP::Response[200,{},body]endendclient=Async::HTTP::Protocol::HTTP2.client(client_io)response=client.call(Protocol::HTTP::Request["GET","/",authority: "localhost",scheme: "http"])sleep1# let the background reader buffer the bodyputs"connection closed: #{client.closed?}"puts"read #{response.read.bytesize} bytes"end
Output:
connection closed: true
protocol-http2-0.28.0/lib/protocol/http2/connection.rb:302:in 'block in Protocol::HTTP2::Connection#write_frame': undefined method 'write_frame' for nil (NoMethodError)
from async-2.46.0/lib/async/semaphore.rb:87:in 'Async::Semaphore#acquire'
from async-http-0.105.0/lib/async/http/protocol/http2/connection.rb:45:in 'Async::HTTP::Protocol::HTTP2::Connection#synchronize'
from protocol-http2-0.28.0/lib/protocol/http2/connection.rb:301:in 'Protocol::HTTP2::Connection#write_frame'
from async-http-0.105.0/lib/async/http/protocol/http2/connection.rb:50:in 'block in Async::HTTP::Protocol::HTTP2::Connection#write_frame'
from async-2.46.0/lib/async/task.rb:400:in 'Async::Task#defer_cancel'
from async-2.46.0/lib/async/task.rb:425:in 'Async::Task#defer_stop'
from async-http-0.105.0/lib/async/http/protocol/http2/connection.rb:50:in 'Async::HTTP::Protocol::HTTP2::Connection#write_frame'
from protocol-http2-0.28.0/lib/protocol/http2/stream.rb:115:in 'Protocol::HTTP2::Stream#write_frame'
from protocol-http2-0.28.0/lib/protocol/http2/flow_controlled.rb:74:in 'Protocol::HTTP2::FlowControlled#send_window_update'
from protocol-http2-0.28.0/lib/protocol/http2/flow_controlled.rb:65:in 'Protocol::HTTP2::FlowControlled#request_window_update'
from async-http-0.105.0/lib/async/http/protocol/http2/input.rb:29:in 'Async::HTTP::Protocol::HTTP2::Input#read'
from protocol-http-0.72.0/lib/protocol/http/body/readable.rb:102:in 'Protocol::HTTP::Body::Readable#each'
from protocol-http-0.72.0/lib/protocol/http/body/readable.rb:118:in 'Protocol::HTTP::Body::Readable#join'
from protocol-http-0.72.0/lib/protocol/http/body/reader.rb:29:in 'Protocol::HTTP::Body::Reader#read'
Activity
jakeonfire commentedon Oct 19, 2026
this patch seems to fix it for us, fwiw