Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response code 429 (Too Many Requests) on successComment #361

Closed
vgropp opened this issue Apr 11, 2022 · 13 comments · Fixed by #800
Closed

Response code 429 (Too Many Requests) on successComment #361

vgropp opened this issue Apr 11, 2022 · 13 comments · Fixed by #800

Comments

@vgropp
Copy link

vgropp commented Apr 11, 2022

We are running into the gitlab API limit on some projects when multiple semantic-releases are running at the same time from share IPs.

[8:07:42 AM] [semantic-release] › ℹ  Start step "success" of plugin "@semantic-release/gitlab"
[8:07:44 AM] [semantic-release] [@semantic-release/gitlab] › ✖  An error occurred while posting comments to related issues and merge requests:
HTTPError: Response code 429 (Too Many Requests)
    at Request.<anonymous> (/usr/local/lib/node_modules/@semantic-release/gitlab/node_modules/got/dist/source/as-promise/index.js:117:42)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'ERR_NON_2XX_3XX_RESPONSE',

As far as I understand the code

const getRelatedIssues = async mergeRequest => {
for very Commit the script is looking for a MR, with those MR the script is searching for an resolved issue. So there will be at least commits * MR Requests. As we do not use gitlab issues (but like the MR comment), what about a configuration to disable the Issue Comments and hence those requests? This will limit the requests to count of commits.

Another Option would be rate limiting the requests, but that seems like a lot more work but more sustainable solution.

@fgreinacher
Copy link
Contributor

Thanks for reporting this @vgropp!

You can disable the new feature by setting the successComment option to false.

Other than that I think it would make sense to add proper handling of such cases to this plugin.

JonasSchubert added a commit to JonasSchubert/gitlab that referenced this issue Jun 1, 2024
…c-release#361

If got receives a response code 429 - too many requests - it will retry up to three times for GET and POST requests.
This uses the retry API https://github.com/sindresorhus/got/blob/main/documentation/7-retry.md
JonasSchubert added a commit to JonasSchubert/gitlab that referenced this issue Jun 2, 2024
…c-release#361

If got receives a response code 429 - too many requests - it will retry up to three times for GET and POST requests.
This uses the retry API https://github.com/sindresorhus/got/blob/main/documentation/7-retry.md
JonasSchubert added a commit to JonasSchubert/gitlab that referenced this issue Jun 2, 2024
…c-release#361

If got receives a response code 429 - too many requests - it will retry up to three times for GET and POST requests.
This uses the retry API https://github.com/sindresorhus/got/blob/main/documentation/7-retry.md
@fgreinacher
Copy link
Contributor

@vgropp Have you seen this behavior recently? In #728 we learned that the underlying HTTP library does actually have a quite powerful retry logic. I'd like to understand why this is not enough in your case. 🙇

@liz72703
Copy link

liz72703 commented Sep 4, 2024

I got this error today. Never happened before.

[5:32:08 PM] [semantic-release] [@semantic-release/gitlab] › ✘ An error occurred while posting comments to related issues and merge requests:
HTTPError: Response code 429 (Too Many Requests)
at Request. (file:///builds//node_modules/got/dist/source/as-promise/index.js:92:42)
at Object.onceWrapper (node:events:633:26)
at Request.emit (node:events:530:35)
at Request._onResponseBase (file:///builds//node_modules/got/dist/source/core/index.js:604:22)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Request._onResponse (file:///builds//node_modules/got/dist/source/core/index.js:646:13) {
input: undefined,
code: 'ERR_NON_2XX_3XX_RESPONSE',
timings: {
start: 1725471128174,
socket: 1725471128178,
lookup: 1725471128178,
connect: 1725471128178,
secureConnect: 1725471128178,
upload: 1725471128178,
response: 1725471128311,
end: 1725471128311,
error: undefined,
abort: undefined,
phases: {
wait: 4,
dns: 0,
tcp: 0,
tls: 0,
request: 0,
firstByte: 133,
download: 0,
total: 137
}
},
options: {
request: undefined,
agent: { http: undefined, https: undefined, http2: undefined },
h2session: undefined,
decompress: true,
timeout: {
connect: undefined,
lookup: undefined,
read: undefined,
request: undefined,
response: undefined,
secureConnect: undefined,
send: undefined,
socket: undefined
},
prefixUrl: '',
body: '{"body":":tada: This MR is included in version 5.5.0 :tada:\n\nThe release is available on GitLab release.\n\nYour semantic-release bot 📦 🚀"}',
form: undefined,
json: undefined,
cookieJar: undefined,
ignoreInvalidCookies: [secure],
searchParams: undefined,
dnsLookup: undefined,
dnsCache: undefined,
context: {},
hooks: {
init: [],
beforeRequest: [],
beforeError: [],
beforeRedirect: [],
beforeRetry: [],
afterResponse: []
},
followRedirect: true,
maxRedirects: 10,
cache: undefined,
throwHttpErrors: true,
username: '',
password: '',
http2: [secure],
allowGetBody: [secure],
headers: {
'user-agent': 'got (https://github.com/sindresorhus/got)',
'private-token': '[secure]',
'content-type': 'application/json',
'content-length': '306',
'accept-encoding': 'gzip, deflate, br'
},
methodRewriting: [secure],
dnsLookupIpVersion: undefined,
parseJson: [Function: parse],
stringifyJson: [Function: stringify],
retry: {
limit: 2,
methods: [ 'GET', 'PUT', 'HEAD', 'DELETE', 'OPTIONS', 'TRACE' ],
statusCodes: [
408, 413, 429, 500,
502, 503, 504, 521,
522, 524
],
errorCodes: [
'ETIMEDOUT',
'ECONNRESET',
'EADDRINUSE',
'ECONNREFUSED',
'EPIPE',
'ENOTFOUND',
'ENETUNREACH',
'EAI_AGAIN'
],
maxRetryAfter: undefined,
calculateDelay: [Function: calculateDelay],
backoffLimit: Infinity,
noise: 100
},
localAddress: undefined,
method: 'POST',
createConnection: undefined,
cacheOptions: {
shared: undefined,
cacheHeuristic: undefined,
immutableMinTimeToLive: undefined,
ignoreCargoCult: undefined
},
https: {
alpnProtocols: undefined,
rejectUnauthorized: undefined,
checkServerIdentity: undefined,
certificateAuthority: undefined,
key: undefined,
certificate: undefined,
passphrase: undefined,
pfx: undefined,
ciphers: undefined,
honorCipherOrder: undefined,
minVersion: undefined,
maxVersion: undefined,
signatureAlgorithms: undefined,
tlsSessionLifetime: undefined,
dhparam: undefined,
ecdhCurve: undefined,
certificateRevocationLists: undefined
},
encoding: undefined,
resolveBodyOnly: [secure],
isStream: [secure],
responseType: 'text',
url: URL {
href: 'https://gitlab.com/api/v4/projects/51037352/merge_requests/360/notes',
origin: 'https://gitlab.com',
protocol: 'https:',
username: '',
password: '',
host: 'gitlab.com',
hostname: 'gitlab.com',
port: '',
pathname: '/api/v4/projects/51037352/merge_requests/360/notes',
search: '',
searchParams: URLSearchParams {},
hash: ''
},
pagination: {
transform: [Function: transform],
paginate: [Function: paginate],
filter: [Function: filter],
shouldContinue: [Function: shouldContinue],
countLimit: Infinity,
backoff: 0,
requestLimit: 10000,
stackAllItems: [secure]
},
setHost: true,
maxHeaderSize: undefined,
signal: undefined,
enableUnixSockets: [secure]
},
[cause]: {}
}
[5:32:08 PM] [semantic-release] › ✘ Failed step "success" of plugin "@semantic-release/gitlab"
[5:32:08 PM] [semantic-release] › ✘ An error occurred while running semantic-release: HTTPError: Response code 429 (Too Many Requests)
at Request. (file:///builds//node_modules/got/dist/source/as-promise/index.js:92:42)
at Object.onceWrapper (node:events:633:26)
at Request.emit (node:events:530:35)
at Request._onResponseBase (file:///builds//node_modules/got/dist/source/core/index.js:604:22)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Request._onResponse (file:///builds//node_modules/got/dist/source/core/index.js:646:13) {
input: undefined,
code: 'ERR_NON_2XX_3XX_RESPONSE',
timings: {
start: 1725471128174,
socket: 1725471128178,
lookup: 1725471128178,
connect: 1725471128178,
secureConnect: 1725471128178,
upload: 1725471128178,
response: 1725471128311,
end: 1725471128311,
error: undefined,
abort: undefined,
phases: {
wait: 4,
dns: 0,
tcp: 0,
tls: 0,
request: 0,
firstByte: 133,
download: 0,
total: 137
}
},
options: {
request: undefined,
agent: { http: undefined, https: undefined, http2: undefined },
h2session: undefined,
decompress: true,
timeout: {
connect: undefined,
lookup: undefined,
read: undefined,
request: undefined,
response: undefined,
secureConnect: undefined,
send: undefined,
socket: undefined
},
prefixUrl: '',
body: '{"body":":tada: This MR is included in version 5.5.0 :tada:\n\nThe release is available on GitLab release.\n\nYour semantic-release bot 📦 🚀"}',
form: undefined,
json: undefined,
cookieJar: undefined,
ignoreInvalidCookies: [secure],
searchParams: undefined,
dnsLookup: undefined,
dnsCache: undefined,
context: {},
hooks: {
init: [],
beforeRequest: [],
beforeError: [],
beforeRedirect: [],
beforeRetry: [],
afterResponse: []
},
followRedirect: true,
maxRedirects: 10,
cache: undefined,
throwHttpErrors: true,
username: '',
password: '',
http2: [secure],
allowGetBody: [secure],
headers: {
'user-agent': 'got (https://github.com/sindresorhus/got)',
'private-token': '[secure]',
'content-type': 'application/json',
'content-length': '306',
'accept-encoding': 'gzip, deflate, br'
},
methodRewriting: [secure],
dnsLookupIpVersion: undefined,
parseJson: [Function: parse],
stringifyJson: [Function: stringify],
retry: {
limit: 2,
methods: [ 'GET', 'PUT', 'HEAD', 'DELETE', 'OPTIONS', 'TRACE' ],
statusCodes: [
408, 413, 429, 500,
502, 503, 504, 521,
522, 524
],
errorCodes: [
'ETIMEDOUT',
'ECONNRESET',
'EADDRINUSE',
'ECONNREFUSED',
'EPIPE',
'ENOTFOUND',
'ENETUNREACH',
'EAI_AGAIN'
],
maxRetryAfter: undefined,
calculateDelay: [Function: calculateDelay],
backoffLimit: Infinity,
noise: 100
},
localAddress: undefined,
method: 'POST',
createConnection: undefined,
cacheOptions: {
shared: undefined,
cacheHeuristic: undefined,
immutableMinTimeToLive: undefined,
ignoreCargoCult: undefined
},
https: {
alpnProtocols: undefined,
rejectUnauthorized: undefined,
checkServerIdentity: undefined,
certificateAuthority: undefined,
key: undefined,
certificate: undefined,
passphrase: undefined,
pfx: undefined,
ciphers: undefined,
honorCipherOrder: undefined,
minVersion: undefined,
maxVersion: undefined,
signatureAlgorithms: undefined,
tlsSessionLifetime: undefined,
dhparam: undefined,
ecdhCurve: undefined,
certificateRevocationLists: undefined
},
encoding: undefined,
resolveBodyOnly: [secure],
isStream: [secure],
responseType: 'text',
url: URL {
href: 'https://gitlab.com/api/v4/projects/51037352/merge_requests/360/notes',
origin: 'https://gitlab.com',
protocol: 'https:',
username: '',
password: '',
host: 'gitlab.com',
hostname: 'gitlab.com',
port: '',
pathname: '/api/v4/projects/51037352/merge_requests/360/notes',
search: '',
searchParams: URLSearchParams {},
hash: ''
},
pagination: {
transform: [Function: transform],
paginate: [Function: paginate],
filter: [Function: filter],
shouldContinue: [Function: shouldContinue],
countLimit: Infinity,
backoff: 0,
requestLimit: 10000,
stackAllItems: [secure]
},
setHost: true,
maxHeaderSize: undefined,
signal: undefined,
enableUnixSockets: [secure]
},
pluginName: '@semantic-release/gitlab',
[cause]: {}
}
AggregateError:
HTTPError: Response code 429 (Too Many Requests)
at Request. (file:///builds//node_modules/got/dist/source/as-promise/index.js:92:42)
at Request._onResponseBase (file:///builds//node_modules/got/dist/source/core/index.js:604:22)
at async Request._onResponse (file:///builds//node_modules/got/dist/source/core/index.js:646:13)
at file:///builds//node_modules/semantic-release/lib/plugins/pipeline.js:55:13
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async pluginsConfigAccumulator. [as success] (file:///builds//node_modules/semantic-release/lib/plugins/index.js:87:11)
at async run (file:///builds//node_modules/semantic-release/index.js:218:3)
at async Module.default (file:///builds//node_modules/semantic-release/index.js:278:22)
at async default (file:///builds//node_modules/semantic-release/cli.js:55:5) {
errors: [
HTTPError: Response code 429 (Too Many Requests)
at Request. (file:///builds//node_modules/got/dist/source/as-promise/index.js:92:42)
at Object.onceWrapper (node:events:633:26)
at Request.emit (node:events:530:35)
at Request._onResponseBase (file:///builds//node_modules/got/dist/source/core/index.js:604:22)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Request._onResponse (file:///builds//node_modules/got/dist/source/core/index.js:646:13) {
input: undefined,
code: 'ERR_NON_2XX_3XX_RESPONSE',
timings: [Object],
options: {
request: undefined,
agent: { http: undefined, https: undefined, http2: undefined },
h2session: undefined,
decompress: true,
timeout: {
connect: undefined,
lookup: undefined,
read: undefined,
request: undefined,
response: undefined,
secureConnect: undefined,
send: undefined,
socket: undefined
},
prefixUrl: '',
body: '{"body":":tada: This MR is included in version 5.5.0 :tada:\n\nThe release is available on GitLab release.\n\nYour semantic-release bot 📦 🚀"}',
form: undefined,
json: undefined,
cookieJar: undefined,
ignoreInvalidCookies: [secure],
searchParams: undefined,
dnsLookup: undefined,
dnsCache: undefined,
context: {},
hooks: {
init: [],
beforeRequest: [],
beforeError: [],
beforeRedirect: [],
beforeRetry: [],
afterResponse: []
},
followRedirect: true,
maxRedirects: 10,
cache: undefined,
throwHttpErrors: true,
username: '',
password: '',
http2: [secure],
allowGetBody: [secure],
headers: {
'user-agent': 'got (https://github.com/sindresorhus/got)',
'private-token': '[secure]',
'content-type': 'application/json',
'content-length': '306',
'accept-encoding': 'gzip, deflate, br'
},
methodRewriting: [secure],
dnsLookupIpVersion: undefined,
parseJson: [Function: parse],
stringifyJson: [Function: stringify],
retry: {
limit: 2,
methods: [ 'GET', 'PUT', 'HEAD', 'DELETE', 'OPTIONS', 'TRACE' ],
statusCodes: [
408, 413, 429, 500,
502, 503, 504, 521,
522, 524
],
errorCodes: [
'ETIMEDOUT',
'ECONNRESET',
'EADDRINUSE',
'ECONNREFUSED',
'EPIPE',
'ENOTFOUND',
'ENETUNREACH',
'EAI_AGAIN'
],
maxRetryAfter: undefined,
calculateDelay: [Function: calculateDelay],
backoffLimit: Infinity,
noise: 100
},
localAddress: undefined,
method: 'POST',
createConnection: undefined,
cacheOptions: {
shared: undefined,
cacheHeuristic: undefined,
immutableMinTimeToLive: undefined,
ignoreCargoCult: undefined
},
https: {
alpnProtocols: undefined,
rejectUnauthorized: undefined,
checkServerIdentity: undefined,
certificateAuthority: undefined,
key: undefined,
certificate: undefined,
passphrase: undefined,
pfx: undefined,
ciphers: undefined,
honorCipherOrder: undefined,
minVersion: undefined,
maxVersion: undefined,
signatureAlgorithms: undefined,
tlsSessionLifetime: undefined,
dhparam: undefined,
ecdhCurve: undefined,
certificateRevocationLists: undefined
},
encoding: undefined,
resolveBodyOnly: [secure],
isStream: [secure],
responseType: 'text',
url: URL {
href: 'https://gitlab.com/api/v4/projects/51037352/merge_requests/360/notes',
origin: 'https://gitlab.com',
protocol: 'https:',
username: '',
password: '',
host: 'gitlab.com',
hostname: 'gitlab.com',
port: '',
pathname: '/api/v4/projects/51037352/merge_requests/360/notes',
search: '',
searchParams: URLSearchParams {},
hash: ''
},
pagination: {
transform: [Function: transform],
paginate: [Function: paginate],
filter: [Function: filter],
shouldContinue: [Function: shouldContinue],
countLimit: Infinity,
backoff: 0,
requestLimit: 10000,
stackAllItems: [secure]
},
setHost: true,
maxHeaderSize: undefined,
signal: undefined,
enableUnixSockets: [secure]
},
pluginName: '@semantic-release/gitlab',
[cause]: {}
}
]
}
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1

@schraal
Copy link

schraal commented Nov 18, 2024

Got this error last week

@jakec-dev
Copy link

Getting this error now

@nejch
Copy link

nejch commented Nov 21, 2024

Just ran into this as well: https://gitlab.com/marge-org/marge-bot/-/pipelines/1554783088

Not a big deal though as the rest of the release is done before and this probably only happens when not releasing often or on the first release when it spams all the issues/MRs.

@OZIOisgood
Copy link

Got this error today

@nejch
Copy link

nejch commented Nov 22, 2024

If all the recent issues reported here are happening on gitlab.com, it could also be that their infrastructure has changed to more aggressive rate limits that the client can't always handle properly anymore.

@fgreinacher
Copy link
Contributor

@OZIOisgood @jakec-dev @schraal @liz72703 Do you remember whether the errors happened on the first release, when semantic-release tried to comment a lot of issues/MRs?

@fgreinacher
Copy link
Contributor

fgreinacher commented Nov 27, 2024

We could try to increase the maximum number of retries, similar to how it was originally suggested in #728 (comment). Right now got will give up after 2 retries.

/cc @JonasSchubert

@jakec-dev
Copy link

@fgreinacher Yes, for our team this only occurs on the first release. Subsequent releases are fine.

Copy link

github-actions bot commented Dec 4, 2024

🎉 This issue has been resolved in version 13.2.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@fgreinacher
Copy link
Contributor

fgreinacher commented Dec 4, 2024

Folks, please upgrade to 13.2.3 where we increased the default retry limit from 2 to 3. You can also play with the new retryLimit option to tune the behavior further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants