dhoulb / multi-semantic-release

Proof of concept that wraps semantic-release to work with monorepos.
BSD Zero Clause License
200 stars 37 forks source link

Rate Limit #115

Closed rafael-jannone-frvr closed 2 years ago

rafael-jannone-frvr commented 2 years ago

Good day,

I'm experimenting with this tool on an existing monorepo. It didn't have any previously published packages, just a lot of commits.

Got to a point where it would start working, when it was able to publish some 3 packages, and stumbled upon a Rate Limit error:

npm notice Publishing to https://npm.pkg.github.com
v1.0.3
[3:07:23 PM] [@my-company/package-a] › ✔  Completed step "prepare" of plugin "Inline plugin"
[3:07:23 PM] [@my-company/package-b] › ✖  Failed step "success" of plugin "@semantic-release/github"
[3:07:23 PM] [@my-company/package-b] › ✖  An error occurred while running semantic-release: RequestError [HttpError]: You have exceeded a secondary rate limit. Please wait a few minutes before you try again.
    at /home/runner/work/my-repo/my-repo/node_modules/@octokit/request/dist-node/index.js:86:21
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  status: 403,
  response: {
    url: 'https://api.github.com/search/issues?q=repo%3Amy-company%2Fmy-repo+type%3Apr+is%3Amerged+xxxxx',
    status: 403,
    headers: {
      'access-control-allow-origin': '*',
      'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
      connection: 'close',
      'content-encoding': 'gzip',
      'content-security-policy': "default-src 'none'",
      'content-type': 'application/json; charset=utf-8',
      date: 'Wed, 11 May 2022 15:07:23 GMT',
      'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
      server: 'GitHub.com',
      'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
      'transfer-encoding': 'chunked',
      vary: 'Accept-Encoding, Accept, X-Requested-With',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'deny',
      'x-github-media-type': 'github.v3; format=json',
      'x-github-request-id': 'xxxxx',
      'x-ratelimit-limit': '30',
      'x-ratelimit-remaining': '29',
      'x-ratelimit-reset': '1652281703',
      'x-ratelimit-resource': 'search',
      'x-ratelimit-used': '1',
      'x-xss-protection': '0'
    },
    data: {
      documentation_url: 'https://docs.github.com/en/free-pro-team@latest/rest/overview/resources-in-the-rest-api#secondary-rate-limits',
      message: 'You have exceeded a secondary rate limit. Please wait a few minutes before you try again.'
    }
  },
  request: {
    method: 'GET',
    url: 'https://api.github.com/search/issues?q=repo%3Amy-company%2Fmy-repo+type%3Apr+is%3Amerged+xxxxx',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit-rest.js/18.12.0 octokit-core.js/3.6.0 Node.js/16.15.0 (linux; x64)',
      authorization: 'token [REDACTED]'
    },
    request: { agent: undefined, hook: [Function: bound bound register] }
  },
  pluginName: '@semantic-release/github'
}
[multi-semantic-release]: AggregateError: 
    HttpError: You have exceeded a secondary rate limit. Please wait a few minutes before you try again.
        at /home/runner/work/my-repo/my-repo/node_modules/@octokit/request/dist-node/index.js:86:21
        at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at /home/runner/work/my-repo/my-repo/node_modules/multi-semantic-release/node_modules/semantic-release/lib/plugins/pipeline.js:54:11
    at async Object.pluginsConf.<computed> [as success] (/home/runner/work/my-repo/my-repo/node_modules/multi-semantic-release/node_modules/semantic-release/lib/plugins/index.js:80:11)
    at async run (/home/runner/work/my-repo/my-repo/node_modules/multi-semantic-release/node_modules/semantic-release/index.js:201:3)
    at async module.exports (/home/runner/work/my-repo/my-repo/node_modules/multi-semantic-release/node_modules/semantic-release/index.js:260:22)
    at async releasePackage (/home/runner/work/my-repo/my-repo/node_modules/multi-semantic-release/lib/multiSemanticRelease.js:201:15)
    at async Promise.all (index 0)
    at async multiSemanticRelease (/home/runner/work/my-repo/my-repo/node_modules/multi-semantic-release/lib/multiSemanticRelease.js:96:2)
Error: Process completed with exit

This repo is under active development, so uploading 3 or more packages at once will certainly happen.

Is there a way to mitigate this issue?

antongolub commented 2 years ago

Hey, @rafael-jannone-frvr,

You can try to add a delay via semantic-release/exec plugin:

{
   plugins: [
    ...
    '@semantic-release/github'
    '@semantic-release/git'
    [
      '@semantic-release/exec',
      {
        sucessCmd: 'sleep 3',
      }
    ],
   ]
}
rafael-jannone-frvr commented 2 years ago

It works! Thanks @antongolub !!

antongolub commented 2 years ago

Great! So I'm closing this issue.