devhub icon indicating copy to clipboard operation
devhub copied to clipboard

Uncaught Exception: TypeError: Cannot read property 'x' of undefined

Open AndreTheHunter opened this issue 3 years ago • 1 comments

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)

Screen Shot 2022-04-11 at 10 02 29

The app seems to continue loading fine...

On MacOS Monterey 12.3 on MacBook Pro (16-inch, 2021)

AndreTheHunter avatar Apr 11 '22 00:04 AndreTheHunter

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.

manojksarkar avatar Jun 02 '24 08:06 manojksarkar