saitho / semantic-release-backmerge

:twisted_rightwards_arrows: semantic-release plugin to back-merge a release into a develop branch
https://saitho.github.io/semantic-release-backmerge/
56 stars 11 forks source link

Retry on particular HTTP errors #41

Closed syphernl closed 1 year ago

syphernl commented 1 year ago

GitLab can throw intermittent 503's, causing this plugin to fail (and thus the entire semantic-release job)

An example of a failure which just occurred.

remote: Service Unavailable
fatal: unable to access 'https://gitlab.example.com/team/project.git/': The requested URL returned error: 503
    at makeError (/usr/local/lib/node_modules/@saithodev/semantic-release-backmerge/node_modules/execa/lib/error.js:60:11)
    at handlePromise (/usr/local/lib/node_modules/@saithodev/semantic-release-backmerge/node_modules/execa/index.js:118:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  shortMessage: 'Command failed with exit code 128: git fetch https://gitlab-ci-token:[secure]@gitlab.example.com/team/project.git',
  command: 'git fetch https://gitlab-ci-token:[secure]@gitlab.example.com/team/project.git',
  escapedCommand: 'git fetch "https://gitlab-ci-token:[secure]@gitlab.example.com/team/project.git"',
  exitCode: 128,
  signal: undefined,
  signalDescription: undefined,
  stdout: '',
  stderr: 'remote: Service Unavailable\n' +
    "fatal: unable to access 'https://gitlab.example.com/team/project.git/': The requested URL returned error: 503",
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false,
  pluginName: '@saithodev/semantic-release-backmerge'
}
AggregateError: 
    Error: Command failed with exit code 128: git fetch https://gitlab-ci-token:[secure]@gitlab.example.com/team/project.git
    remote: Service Unavailable
    fatal: unable to access 'https://gitlab.example.com/team/project.git/': The requested URL returned error: 503
        at makeError (/usr/local/lib/node_modules/@saithodev/semantic-release-backmerge/node_modules/execa/lib/error.js:60:11)
        at handlePromise (/usr/local/lib/node_modules/@saithodev/semantic-release-backmerge/node_modules/execa/index.js:118:26)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at /usr/local/lib/node_modules/semantic-release/lib/plugins/pipeline.js:54:11
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async pluginsConf.<computed> [as success] (/usr/local/lib/node_modules/semantic-release/lib/plugins/index.js:80:11)
    at async run (/usr/local/lib/node_modules/semantic-release/index.js:209:3)
    at async module.exports (/usr/local/lib/node_modules/semantic-release/index.js:269:22)
    at async module.exports (/usr/local/lib/node_modules/semantic-release/cli.js:55:5)

Would there be a way to handle 503 by retrying for a few times until it does (or until the wait time is over)?

saitho commented 1 year ago

Sounds useful and should be possible :)

saitho commented 1 year ago

It should now retry up to 3 times with 1 seconds in between for all errors on remote Git commands Let me know if that is sufficient. :)

saitho commented 1 year ago

:tada: This issue has been resolved in version 3.1.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: