When BodyHandler
isn't the first handler, request may get stuck (not processed, client times out)
#2438
Labels
BodyHandler
isn't the first handler, request may get stuck (not processed, client times out)
#2438
Version
4.4.3
Context
When setting up
BodyHandler
to process request bodies, if theBodyHandler
is not the first handler (and the previous handlers take a bit of time to finish processing), then theBodyHandler.handle()
method will not callRoutingContext.next()
and will not pass processing to the next handler. As a result the request isn't being processed and the client will eventually time out and get an error.I normally would like to do some processing on the headers before I commit to parse the body (reading authorization headers and looking them up in the database, nominally), or - if
BodyHandler
will fail (for example withPayload Too Large
) I would still want to do some generic processing, such as logging the failed request using a logging handler, adding server-specific response headers, etc.Do you have a reproducer?
This reproducer has a handler with a 50ms delay before calling the body handler, to simulate some IO.
Steps to reproduce
BodyHandler
Extra
I'm not really clear if it is even possible for
BodyHandler
to work correctly if it isn't the first handler, but IMHO my points still stand:BodyHandler
gives up - it should fail the request with an appropriate exception, not just be like 🤷 and drop the request on the floor.BodyHandler
completes reading and parsing the body - ifBodyHandler
needs to register callbacks early or something, then it should be able to let it to do that but not block all the other handlers until all the request data has been read from the socket (which can take a long time and we might just want to close the socket early or sth).The text was updated successfully, but these errors were encountered: