diff --git a/lib/shared/sdk/usbboot/index.js b/lib/shared/sdk/usbboot/index.js index bdc67738..de9db7af 100644 --- a/lib/shared/sdk/usbboot/index.js +++ b/lib/shared/sdk/usbboot/index.js @@ -400,7 +400,17 @@ exports.scan = (options) => { const deviceInterface = device.interface(addresses.interface) debug(`Claiming interface: ${addresses.interface}`) - deviceInterface.claim() + + try { + deviceInterface.claim() + } catch (error) { + if (error.message === 'LIBUSB_ERROR_NO_DEVICE') { + debug('Couldn\'t claim the interface. Assuming the device is gone') + return null + } + + throw error + } const endpoint = deviceInterface.endpoint(addresses.endpoint) @@ -429,5 +439,5 @@ exports.scan = (options) => { // See http://bluebirdjs.com/docs/api/promise.map.html }, { concurrency: 5 - }) + }).then(_.compact) }