-
-
Notifications
You must be signed in to change notification settings - Fork 28
Async::IO::Stream#write
doesn't flush to IO even when sync
is true
#79
Comments
An alternative would be maintaining the current behavior for |
Apologies for the delayed response, I've been dealing with a bunch of bug reports from the Ruby v3.3.0 release and ensuring we backport all the appropriate fixes that are on my radar. So, I've been thinking about this problem and want to elaborate a couple of points. I'd really like to deprecate To this end, I've been:
I'm okay to fix things here in I'm also certain we want to be careful around buffering IO, and explicit w.r.t. HTTP/2, I think flush only makes sense when you are expecting to read a response, or need to reduce round-trip latency (i.e. send this message right away). Regarding the connection preface, it's probably not a bad idea to flush it right away. Sorry for the brain dump, but:
|
I just took a look at the However, if For this, I think a conditional flush when there's a block would address it. # protocol-http2's client.rb
def send_connection_preface(settings = [])
if @state == :new
@framer.write_connection_preface
send_settings(settings)
### begin: changes
if block_given?
# I believe @stream is only valid in async-http's subclass, so may need to be @framer.stream.flush
@stream.flush
yield
end
### end: changes
read_frame do |frame|
raise ProtocolError, "First frame must be #{SettingsFrame}, but got #{frame.class}" unless frame.is_a? SettingsFrame
end
else
raise ProtocolError, "Cannot send connection preface in state #{@state}"
end
end @maruth-stripe, does that seem like it would address the issue as you understand it? PS: This doesn't address the question or usefulness of adding |
Sorry, I realise there is a bunch of stuff to unpack here, I'll try to circle back to it soon. |
What the title says.
In contrast to the documentation, the method only flushes when the
write_buffer
is full. This is what's causing the tests to hang in my PR to protocol-http2.Specifically here in
test/protocol/http2/client.rb
it sends the connection preface, but that is too small to fill up the write buffer so it never gets flushed. Hence the followingframer.read_connection_preface
indefinitely hangs.Changing the
Async::IO::Stream#write
tofixes it, and the test suite works. Is the unconditional buffering intended?
The text was updated successfully, but these errors were encountered: