Reprocess failed ajax request.#1366
Conversation
When an ajax request fails the client will resend the request. With this patch, if the failure is caused by the server (http code >500) the retry-request will actually be processed again instead of being satisfied by the previously computed response (which was a failure)
There was a problem hiding this comment.
Given that this is only used here, I'm not sure having an extra indirection through the CachedResponse class is needed. Why not just perform the code check directly here and act accordingly? Something like:
result match {
case Full(response) if response.code >= 500 && response.code < 600 =>
// The request failed...
liftSession.with...
case other =>
future.satisfy(other)
}There was a problem hiding this comment.
Oh, in this case, for any pending requests, we should also still satisfy the future with the result.
There was a problem hiding this comment.
But LiftResponse doesnt have code, only toResponse. So we end up calling toResponse twice (here and where the response is actually sent)
I'm unsure why this is so but assumes there's a reason :-)
There was a problem hiding this comment.
Aha, I see. That does indeed complicate things. @dpp does this look reasonable to you then?
There was a problem hiding this comment.
Please give it a try and see how it works in the wild. ;-)
|
As discussed on the mailing list, closing this pull request until Jeppe (or anyone else) has time to implement "Oh, in this case, for any pending requests, we should also still satisfy the future with the result." (Just to avoid merging it to master until it is ready) |
|
Updated. Sorry for the delay :-) |
|
+1 looks good. |
|
rebased to master |
When an ajax request fails the client will resend the request.
With this patch, if the failure is caused by the server (http code >500) the retry-request will actually be processed again instead of being satisfied by the previously computed response (which was a failure)