diff --git a/lib/shared/sdk/usbboot/index.js b/lib/shared/sdk/usbboot/index.js index bc79a1c3..fd8a4ac5 100644 --- a/lib/shared/sdk/usbboot/index.js +++ b/lib/shared/sdk/usbboot/index.js @@ -376,8 +376,14 @@ exports.scan = (options) => { debug('Starting file server') return startFileServer(device, endpoint, options.files) - }).return(device).finally(() => { - device.close() + }).return(device).catch({ + message: 'LIBUSB_TRANSFER_CANCELLED' + }, { + message: 'LIBUSB_ERROR_NO_DEVICE' + }, _.constant(null)).tap((result) => { + if (result) { + result.close() + } }) // See http://bluebirdjs.com/docs/api/promise.map.html