gayanvoice / top-github-users

Check your ranking in GitHub! Don't forget to star ⭐ this repository.
https://github.com/gayanvoice/top-github-users-action
3.89k stars 582 forks source link

Ukraine is failing due to a timeout #107

Open jsoref opened 1 year ago

jsoref commented 1 year ago

https://github.com/gayanvoice/top-github-users/actions/runs/3745728170/jobs/6360444412#step:4:137

RequestError [HttpError]: {
   "data": null,
   "errors":[
      {
         "message":"Something went wrong while executing your query. This may be the result of a timeout, or it could be a GitHub bug. Please include `D3C2:1AFB:7226D1:76338B:63A2690D` when reporting this issue."
      }
   ]
}
: {"message":"Something went wrong while executing your query. This may be the result of a timeout, or it could be a GitHub bug. Please include `D3C2:1AFB:7226D1:76338B:63A2690D` when reporting this issue."}

...

    body: '{"query":"query {\\n              search(type: USER, query:\\"location:ukraine location:kyiv location:lviv location:kharkiv location:odesa  sort:followers-desc\\", first:10, after:null) {\\n                edges {\\n                  node {\\n                    __typename\\n                    ... on User {\\n                      login,\\n                      avatarUrl(size: 72),\\n                      name,\\n                      location,\\n                      company,\\n                      twitterUsername,\\n                      followers {\\n                        totalCount\\n                      }\\n                      contributionsCollection {\\n                        contributionCalendar {\\n                          totalContributions\\n                        }\\n                        restrictedContributionsCount\\n                      }\\n                    }\\n                  }\\n                }\\n                 pageInfo {\\n                    endCursor\\n                    hasNextPage\\n                  }\\n              }\\n            }"}'

I opened a ticket to github support, and they replied:

I took a look and it seems the query in itself is timing out --All API requests, both for the REST API and GraphQL API, have a 10 second limit on execution time. If that limit is reached for a request, the request is terminated and you get back that error.

This normally happens when your query involves too much data, so the way to avoid timeouts is to write smaller queries. If you have a query that touches a lot of data -- split it into several smaller queries and execute them separately.

In my tests, I noticed running the search by filtering the location to just one city at a time reduced the execution time and thus returns a non-error response.

{
  search(
    type: USER
    query: "location:Odesa sort:followers-desc"
    first: 10
    after: null
  ) {
    edges {
      node {
        __typename
        ... on User {
          login
          avatarUrl(size: 72)
          name
          location
          company
          twitterUsername
          followers {
            totalCount
          }
          contributionsCollection {
            contributionCalendar {
              totalContributions
            }
            restrictedContributionsCount
          }
        }
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }

It appears that you'd want to split the query by city and then merge and filter the results.