devhub
devhub copied to clipboard
Uncaught Exception: TypeError: Cannot read property 'x' of undefined
On startup I get the following error:
Uncaught Exception:
TypeError: Cannot read property 'x' of undefined
at getBrowserWindowOptions (/Applications/DevHub.app/Contents/Resources/app.asar/dist/window.js:171:39)
at createWindow (/Applications/DevHub.app/Contents/Resources/app.asar/dist/window.js:67:46)
at Object.updateOrRecreateWindow (/Applications/DevHub.app/Contents/Resources/app.asar/dist/window.js:210:22)
at App.<anonymous> (/Applications/DevHub.app/Contents/Resources/app.asar/dist/index.js:113:16)
at App.emit (events.js:315:20)

The app seems to continue loading fine...
On MacOS Monterey 12.3 on MacBook Pro (16-inch, 2021)
I've implemented the optional chaining to handle the potential undefined values for menubarWindowState and mainWindowState. The updated code snippet is as follows:
...(config.store.get('isMenuBarMode')
? {
x: menubarWindowState?.x,
y: menubarWindowState?.y,
width: menubarWindowState?.width,
height: menubarWindowState?.height,
alwaysOnTop: true,
center: false,
frame: false,
fullscreenable: false,
maxWidth: screen.getDisplayFromCursor().size.width * 0.9,
maxHeight: screen.getDisplayFromCursor().size.height,
movable: false,
skipTaskbar: true,
}
: {
x: mainWindowState?.x,
y: mainWindowState?.y,
width: mainWindowState?.width,
height: mainWindowState?.height,
alwaysOnTop: false,
center: true,
frame: constants.FRAME_IS_DIFFERENT_BETWEEN_MODES,
fullscreenable: true,
maxWidth: undefined,
maxHeight: undefined,
movable: !config.store.get('lockOnCenter'),
skipTaskbar: false,
}),
As I don't have macOS, I couldn't verify whether the above check is working well or not. If it is not working as expected, please ensure that the init() function is called before this function.