Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[core] Style request doesn't get retried on mbgl::NetworkStatus::Reachable() #7902

Merged
merged 3 commits into from
Feb 7, 2017

Conversation

tmpsantos
Copy link
Contributor

Steps to trigger behavior

  1. Set a style URL with the network connection down and empty cache.
  2. Turn the network connection up.
  3. Call mbgl::NetworkStatus::Reachable()

Expected behavior

Style request gets retried and we see a map.

Actual behavior

Blank map.

@tmpsantos tmpsantos added bug Core The cross-platform C++ core, aka mbgl labels Jan 30, 2017
@tmpsantos tmpsantos self-assigned this Jan 30, 2017
@tmpsantos tmpsantos force-pushed the tmpsantos-7902_style_retry branch from b6847f3 to 17209bb Compare February 6, 2017 16:46
@tmpsantos tmpsantos requested a review from jfirebaugh February 6, 2017 16:49
@@ -35,7 +35,7 @@ class Response {
optional<std::string> etag;

bool isFresh() const {
return !expires || *expires > util::now();
return (!expires || *expires > util::now()) && !error;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.
@tmpsantos tmpsantos force-pushed the tmpsantos-7902_style_retry branch from 17209bb to 24f13e7 Compare February 6, 2017 18:51
@tmpsantos
Copy link
Contributor Author

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.

Now I see. expires ? *expires > util::now() : !error is indeed the desired.

@tmpsantos tmpsantos force-pushed the tmpsantos-7902_style_retry branch from 24f13e7 to a03187d Compare February 6, 2017 19:45
@tmpsantos tmpsantos merged commit 9279b19 into master Feb 7, 2017
@tmpsantos tmpsantos deleted the tmpsantos-7902_style_retry branch February 7, 2017 11:17
1ec5 added a commit that referenced this pull request Feb 9, 2017
Added mention of #7786, #7989, #7902. Moved #7956 to the correct section.
1ec5 added a commit that referenced this pull request Feb 9, 2017
Added mention of #7786, #7989, #7902. Moved #7956 to the correct section.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Core The cross-platform C++ core, aka mbgl
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants