diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index b5b2a457d..4fd88e2c7 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -30,5 +30,6 @@ - @xen-orchestra/backups patch +- xen-api patch diff --git a/packages/xen-api/src/index.js b/packages/xen-api/src/index.js index 2c40747b3..f329ad922 100644 --- a/packages/xen-api/src/index.js +++ b/packages/xen-api/src/index.js @@ -520,24 +520,34 @@ export class Xapi extends EventEmitter { ) if (pTaskResult !== undefined) { - pTaskResult = pTaskResult.catch(error => { - error.url = response.url - throw error - }) - } + if (useHack) { + // In case of the hack, ignore (but log) the very probably `VDI_IO_ERROR` because it is usually irrelevant + pTaskResult = pTaskResult.catch(error => { + console.warn(this._humanId, 'Xapi#putResource', pathname, error) + }) + } else { + pTaskResult = pTaskResult.catch(error => { + error.url = response.url + throw error + }) - if (!useHack) { - // consume the response - response.resume() - - return pTaskResult + // avoid unhandled rejection in case the upload fails + pTaskResult.catch(noop) + } } const { req } = response if (!req.finished) { await fromEvents(req, ['close', 'finish']) } - response.cancel() + + if (useHack) { + response.cancel() + } else { + // consume the response + response.resume() + } + return pTaskResult }