fix(xen-api/putResource): fix a number of issues
- hide `VDI_IO_ERROR` when using content-length hack - avoid unhandled rejection in case upload fails
This commit is contained in:
parent
4bf81ac33b
commit
2f65a86aa0
@ -30,5 +30,6 @@
|
||||
<!--packages-start-->
|
||||
|
||||
- @xen-orchestra/backups patch
|
||||
- xen-api patch
|
||||
|
||||
<!--packages-end-->
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user