diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 54f04db64..a19ea10de 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -16,6 +16,7 @@ - [IPs] Handle space-delimited IP address format provided by outdated guest tools [5801](https://github.com/vatesfr/xen-orchestra/issues/5801) (PR [5805](https://github.com/vatesfr/xen-orchestra/pull/5805)) - [API/pool.listPoolsMatchingCriteria] fix `unknown error from the peer` error (PR [5807](https://github.com/vatesfr/xen-orchestra/pull/5807)) +- [Backup] Limit number of connections to hosts, which should reduce the occurences of `ECONNRESET` ### Packages to release diff --git a/packages/xen-api/package.json b/packages/xen-api/package.json index c8c9eb581..3a23867a1 100644 --- a/packages/xen-api/package.json +++ b/packages/xen-api/package.json @@ -38,6 +38,7 @@ "jest-diff": "^26.4.2", "json-rpc-protocol": "^0.13.1", "kindof": "^2.0.0", + "limit-concurrency-decorator": "^0.5.0", "lodash": "^4.17.4", "make-error": "^1.3.0", "minimist": "^1.2.0", diff --git a/packages/xen-api/src/index.js b/packages/xen-api/src/index.js index 98d762521..4a11ef6f1 100644 --- a/packages/xen-api/src/index.js +++ b/packages/xen-api/src/index.js @@ -7,6 +7,7 @@ import { Collection } from 'xo-collection' import { EventEmitter } from 'events' import { map, noop, omit } from 'lodash' import { cancelable, defer, fromCallback, fromEvents, ignoreErrors, pDelay, pRetry, pTimeout } from 'promise-toolbox' +import { limitConcurrency } from 'limit-concurrency-decorator' import autoTransport from './transports/auto' import coalesceCalls from './_coalesceCalls' @@ -88,6 +89,8 @@ export class Xapi extends EventEmitter { this._RecordsByType = { __proto__: null } this._reverseHostIpAddresses = opts.reverseHostIpAddresses ?? false + this._call = limitConcurrency(opts.callConcurrency ?? 20)(this._call) + this._roCallRetryOptions = { delay: 1e3, tries: 10,