Skip to content

postinstall script easily runs afoul of github rate limits #9

@kdvolder

Description

@kdvolder

The rate limit on github (unauthenticated) api requests is only 60 request per hour. The postinstall script seems to be making these kinds of requests. So it is really quite easy to exceed that limit, especially when builds are being run on a shared CI build infrastructure.

When the limits are exceeded builds that depend on vscode-ripgrep will start seeing these kind of errors causing them to fail (and I found the error somewhat cryptic and hard to diagnose):

error /theia-app/node_modules/vscode-ripgrep: Command failed.
Exit code: 1
Command: node ./lib/postinstall.js
Arguments: 
Directory: /theia-app/node_modules/vscode-ripgrep
Output:
Finding release for v11.0.1-2
GET https://api.github.com/repos/microsoft/ripgrep-prebuilt/releases/tags/v11.0.1-2
Deleting invalid download cache
Downloading ripgrep failed: Error: Request failed: 403
    at ClientRequest.https.get.response (/theia-app/node_modules/vscode-ripgrep/lib/download.js:106:24)
    at Object.onceWrapper (events.js:286:20)
    at ClientRequest.emit (events.js:198:13)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:556:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)
    at TLSSocket.socketOnData (_http_client.js:442:20)
    at TLSSocket.emit (events.js:198:13)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at TLSSocket.Readable.push (_stream_readable.js:224:10)

I was able to confirm the nature of the problem is github rate limit by adding an explicit curl request to my build:

curl -H https://api.github.com/repos/microsoft/ripgrep-prebuilt/releases/tags/v11.0.1-2
{
  "message": "API rate limit exceeded for XXX.XXX.XXX.XXX (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)",
  "documentation_url": "https://developer.github.com/v3/#rate-limiting"
}

This is quite annoying really, as it can be quite hard to know which builds on a shared build infrastructure are actually responsible for exceeding the rate limit for various addresses in build-infrastructure's ip address pool.

Is there any recommended/known way to work around this problem and avoid running up against this limit?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions