diff --git a/app-shell/src/system-info/__tests__/usb-devices.test.ts b/app-shell/src/system-info/__tests__/usb-devices.test.ts index 101da496671..1ae63e9776c 100644 --- a/app-shell/src/system-info/__tests__/usb-devices.test.ts +++ b/app-shell/src/system-info/__tests__/usb-devices.test.ts @@ -3,6 +3,7 @@ import { usb } from 'usb' import * as Fixtures from '@opentrons/app/src/redux/system-info/__fixtures__' import { createUsbDeviceMonitor, getWindowsDriverVersion } from '../usb-devices' +import { isWindows } from '../../os' jest.mock('execa') jest.mock('usb') @@ -76,7 +77,9 @@ const mockUSBDevice = { close: usbDeviceClose, } -describe('app-shell::system-info::usb-devices', () => { +const describeIfNotWindows = isWindows() ? describe.skip : describe + +describeIfNotWindows('app-shell::system-info::usb-devices::detection', () => { const { windowsDriverVersion: _, ...mockDevice } = Fixtures.mockUsbDevice afterEach(() => { jest.resetAllMocks() @@ -194,6 +197,13 @@ describe('app-shell::system-info::usb-devices', () => { reject(new Error('detachListener was not created')) } })) +}) + +describe('app-shell::system-info::usb-devices', () => { + const { windowsDriverVersion: _, ...mockDevice } = Fixtures.mockUsbDevice + afterEach(() => { + jest.resetAllMocks() + }) it('can get the Windows driver version of a device', () => { execaCommand.mockResolvedValue({ stdout: '1.2.3' } as any) diff --git a/app-shell/src/system-info/usb-devices.ts b/app-shell/src/system-info/usb-devices.ts index 568e39a4497..30ed5a53dc2 100644 --- a/app-shell/src/system-info/usb-devices.ts +++ b/app-shell/src/system-info/usb-devices.ts @@ -117,7 +117,7 @@ function upstreamDeviceFromUsbDeviceWinAPI( // pid return execa .command( - `Get-WmiObject Win32_PnpEntity -Filter "DeviceId like '%\\VID_${idVendor( + `Get-WmiObject Win32_PnpEntity -Filter "DeviceId like '%\\\\VID_${idVendor( device )}&PID_${idProduct( device @@ -228,15 +228,20 @@ function upstreamDeviceFromUsbDeviceLibUSB( ] }) .finally(() => { - try { - device.close() - } catch (err) { - log.warn( - `Failed to close vid=${idVendor(device)}, pid=${idProduct( - device - )} in err handler: ${err}` - ) - } + setImmediate(() => { + try { + device.close() + log.info( + `closed vid=${idVendor(device)}, pid=${idProduct(device)} ok` + ) + } catch (err) { + log.info( + `failed to close vid=${idVendor(device)}, pid=${idProduct( + device + )}: ${err}` + ) + } + }) }) }