Skip to content

Commit

Permalink
fix(app-shell): monitor usb only once (#15047)
Browse files Browse the repository at this point in the history
We've observed a crash in the app node side that occurs inside
usb-detection likely to do with some surprisingly-shaped descriptors,
and those descriptors are polled only (a) on request or (b) when you
initialize a webusb device. So let's remove the webusb device
initialization and see if that helps.

Also, the webusb connect listeners are as far as I can tell completely
duplicative of the listeners in system-info/usb-devices, I wonder if
this was a merge conflict?

Closes RQA-2641
  • Loading branch information
sfoster1 authored Apr 30, 2024
1 parent 0eb749f commit aa4a835
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions app-shell/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import electronDebug from 'electron-debug'
import dns from 'dns'
import contextMenu from 'electron-context-menu'
import * as electronDevtoolsInstaller from 'electron-devtools-installer'
import { webusb } from 'usb'

import { createUi, registerReloadUi } from './ui'
import { initializeMenu } from './menu'
Expand All @@ -18,7 +17,6 @@ import { registerSystemInfo } from './system-info'
import { registerProtocolStorage } from './protocol-storage'
import { getConfig, getStore, getOverrides, registerConfig } from './config'
import { registerUsb } from './usb'
import { createUsbDeviceMonitor } from './system-info/usb-devices'
import { registerNotify, closeAllNotifyConnections } from './notifications'

import type { BrowserWindow } from 'electron'
Expand Down Expand Up @@ -57,8 +55,6 @@ if (config.devtools) app.once('ready', installDevtools)

app.once('window-all-closed', () => {
log.debug('all windows closed, quitting the app')
webusb.removeEventListener('connect', () => createUsbDeviceMonitor())
webusb.removeEventListener('disconnect', () => createUsbDeviceMonitor())
app.quit()
closeAllNotifyConnections()
.then(() => {
Expand All @@ -77,8 +73,6 @@ function startUp(): void {
log.error('Uncaught Promise rejection: ', { reason })
)

webusb.addEventListener('connect', () => createUsbDeviceMonitor())
webusb.addEventListener('disconnect', () => createUsbDeviceMonitor())
mainWindow = createUi()
rendererLogger = createRendererLogger()

Expand Down

0 comments on commit aa4a835

Please sign in to comment.