diff --git a/lib/services.js b/lib/services.js index b85fcdaa8d..e1e7ce8181 100644 --- a/lib/services.js +++ b/lib/services.js @@ -425,12 +425,25 @@ const services = { const objGetInfo = objectMD.location; // special case that prevents azure blocks from unecessary deletion // will return null if no need - return data.protectAzureBlocks(bucketName, objectKey, objGetInfo, log, err => { - if (err) { - return cb(err); - } - return deleteMDandData(); - }); + // A synchronous throw in the data layer (e.g. no backend client for a location + // that was removed from the overlay) must not escape into the promise machinery: + // it surfaces there as an unhandledRejection and takes the whole process down. + try { + return data.protectAzureBlocks(bucketName, objectKey, objGetInfo, log, err => { + if (err) { + return cb(err); + } + return deleteMDandData(); + }); + } catch (err) { + log.error('deleteObject: error protecting azure blocks', { + method: 'services.deleteObject', + error: err.message, + bucketName, + objectKey, + }); + return cb(errors.InternalError); + } }, /**