Refined-github: Repository Creation date is incorrect.

Created on 12 Jul 2020  ·  11Comments  ·  Source: sindresorhus/refined-github

This project was created a few months ago (I made the repo and I'm not even 19)

URL: https://github.com/JesterOrNot/MathExpression

image

Please! ♥︎ bug good first issue help wanted

All 11 comments

Dont know what happened there but I get 2 months

image

Screen Shot 2020-07-12 at 15 13 28

Also can't replicate. Firefox

@JesterOrNot this is because this feature needs a personal token set in the options. If you set it, the age will be correct (after the cache is cleared at the bottom of the options page)

@yakov116 how do you think we should handle this? Why is the item shown even if the API throws an error?

What I think is happening they had a very old cache version and when it re-ran without an api key, it went haywire. Does that make any sense??
I tried it without a token and the feature never runs.

I can try it out later tonight and see if that happens.

@fregante confirmed. I changed it to fetch dom and did not provide a commit link. The issue is that we removed the shouldRevalidate. Any one the just updated their refined-github (they did not use it in a while) will have this issue.

image

Add the should revalidate back? or just ignore?

No, we're good, thanks for checking. We merged that update 43 days ago and the cache was set to expire after 30 days anyway, not many will see this unless they just updated RGH.

The timestamp reported in the cache of https://github.com/sindresorhus/refined-github/issues/3394 is actually in the past (June 18th) but cache.function still returns the expired value.

Here's what's happening:

  1. ✅ Expired items are not automatically cleared daily (https://github.com/fregante/webext-storage-cache/issues/7), but if you call cache.get you will receive undefined and the item will be deleted.
  2. cache.function doesn't use this "smart" cache.get because the intent is to immediately write a new value if the past one is expired. This skips an unnecessary deletion.
  3. ⚠️ The problem is that it does not check whether the item is expired at all, so it returns it and then later _revalidates_ it: https://github.com/fregante/webext-storage-cache/issues/21
  4. ❌ If the supplied getter function throws (like in this case if the token is missing), the _revalidation_ fails and the cache is never updated.

I'll reopen this to give visibility to https://github.com/fregante/webext-storage-cache/issues/21

PR welcome

Hi on my repository I have a main branch master and an orphan branch gh-pages where I put built documentation. The repository age value uses the gh-pages branch first commit instead of master.

This results in a very incorrect repository age calculation. I think it should take into account orphaned branches, or perhaps it should always use the default branch or main branch of the repository, not other branches.

Indeed, that happens if you visit the secondary branch _first_, so it caches that one.

The feature ended up becoming a bit complex. I think it can be reduced to 2 simple API calls. This one and then what's in getRepoAge (merged into a single cached function):

{
  repository(owner: "sindresorhus", name: "refined-github") {
    defaultBranchRef {
      target {
        oid
        ... on Commit {
          history {
            totalCount
          }
        }
      }
    }
  }
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

shivapoudel picture shivapoudel  ·  3Comments

durka picture durka  ·  3Comments

yakov116 picture yakov116  ·  3Comments

Arcanemagus picture Arcanemagus  ·  3Comments

Celthi picture Celthi  ·  3Comments