vertx-web
vertx-web copied to clipboard
Log (LoggerHandlerImpl) swallows/loses log if client closes connection.
As discussed from: https://github.com/eclipse-vertx/vert.x/issues/3902
Version 3.9.x
Context Log is not logged
Do you have a reproducer? No.
Steps to reproduce This is coming from conversation here: https://groups.google.com/g/vertx/c/CZaPXYk2MA0
Add LoggerHandlerImpl to your route as early as possible. Make sure immediate is false, so that the log gets loged at the end of the request to ensure that context.addBodyEndHandler(v -> log(context, timestamp, remoteClient, version, method, uri)); is used.
Have client connect and drop close the connection before response is returned.
So I tested this on my own handler with the suggestion of using ctx.addEndHandler()
1- ctx.addBodyEndhanlder()
fires only after success of ctx.response().end()
this allows to create true "filter" style handler. For example: A handler that tracks how long the request/response took. But this doesn't work as indicated if the connection is closed or if ctx.response().end()
fails.
2- ctx.addEndHandler()
works and fires as indicated regardless if the ctx.response().end()
happened and thats where the problem with this is. If you call ctx.response().end()
in async manner. For example: You respond once you have the response from a downstream service then ctx.addEndHandler()
would have already fired before giving the response.
@javadevmtl so you're saying that the endHandler triggers before the end() completes? If that is the case, then the bug is that the endHandler()
should be only after it completes but we need to check how feasable that is.
Chasing down the endHandler call, it goes to vertx-core. There is is called once the final buffer
is send to the network usually right after the bodyHandler
.
Once the data is passed to the network layer (netty) we don't have more control, that is why you can't really account for the download time.