Request.addCompletionListener()
may run the listener before the request is fully complete
#12805
Labels
Request.addCompletionListener()
may run the listener before the request is fully complete
#12805
Jetty version(s)
12.1.x
Description
When using H2,
CompletionStreamWrapper.onCompletion()
may run while some stream may still have some buffers to write. This can be triggered when the client send a reset frame for a request that is busy downloading a lot of data.Since all the ee* implementations register a completion listener to call
HttpOutput.recycle()
, we may recycle a buffer that hasn't been written yet but should.The symptoms are that the client receives an invalid H2 frame when the bug occurs then reacts by immediately sending a go away frame: Chrome does exactly that and logs a
ERR_HTTP2_PROTOCOL_ERROR
as the request's status in its Developer Tools' Network tab.Adding the following log in ee9's
HttpOutput
:triggers the following log that got captured while reproducing this problem:
Reproducing this error requires downloading large amount of data over a slow WAN link while triggering the client to send H2 resets. A common use-case is to stream a video with the html
<video>
tag from a handler that supports ranges and repeatedly seeking in the video: each time the video seeking cursor is moved, Chrome cancels the current download and sends a new request to download the appropriate range.As a workaround, a non-pooling pool can be configured so that the buffers don't get re-pooled and reset while another thread is about to write them.
The text was updated successfully, but these errors were encountered: