-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[core] Style request doesn't get retried on mbgl::NetworkStatus::Reachable() #7902
Conversation
b6847f3
to
17209bb
Compare
include/mbgl/storage/response.hpp
Outdated
@@ -35,7 +35,7 @@ class Response { | |||
optional<std::string> etag; | |||
|
|||
bool isFresh() const { | |||
return !expires || *expires > util::now(); | |||
return (!expires || *expires > util::now()) && !error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this condition be expires ? *expires > util::now() : !error
? In case there is an explicit Cache-Control
or Expires
header on an error response, it should be respected.
Also, error
can be Reason::NotFound
(404). We should carefully consider (and test) what the retry behavior is in that situation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this condition be expires ? *expires > util::now() : !error? In case there is an explicit Cache-Control or Expires header on an error response, it should be respected.
I think they are logically the same. But yours is definitely easier to read.
Also, error can be Reason::NotFound (404). We should carefully consider (and test) what the retry behavior is in that situation.
Currently NotFound doesn't trigger a retry which makes sense, specially for tiles. I can't think of a use case we should retry for styles.
I added 2 more tests to make sure this is what we want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they are logically the same. But yours is definitely easier to read.
In the case that error
and expires
are both set, (!expires || *expires > util::now()) && !error
is always false, but expires ? *expires > util::now() : !error
compares expires
to the current time and ignores error
. I'm arguing that the latter is the desired behavior.
Currently NotFound doesn't trigger a retry which makes sense, specially for tiles.
I don't think this is the case. Imagine the scenario where someone uploads a tileset for a small area, and then expands it to cover a larger area. If you cached a 404 for tiles outside the original boundary, you'd want to be able to obtain the newly available tiles when that cached 404 expires.
It has the unwanted side effect of not retrying anymore in case of error.
17209bb
to
24f13e7
Compare
Now I see. |
24f13e7
to
a03187d
Compare
Steps to trigger behavior
Expected behavior
Style request gets retried and we see a map.
Actual behavior
Blank map.