mawie81 / electron-window-state

A library to store and restore window sizes and positions for your Electron app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WindowState.manage(win) makes BrowserWindow.loadURL() reject promise in electron 5.0.0+ (using 5.0.1))

mithom opened this issue · comments

the URL will be successfully loaded, but the returned promise (feature from electron 5.0.0) will be rejected.

I cant reproduce this. Do you have a sample where this happens?
My minimal test:

const { app, BrowserWindow } = require('electron');
const windowStateKeeper = require('electron-window-state');
let win;

function createWindow() {
  let mainWindowState = windowStateKeeper({
    defaultWidth: 1000,
    defaultHeight: 800,
  });

  // Create the browser window.
  win = new BrowserWindow({
    x: mainWindowState.x,
    y: mainWindowState.y,
    width: mainWindowState.width,
    height: mainWindowState.height,
  });

  win
    .loadURL('https://google.com')
    .then(() => console.log('resolve'))
    .catch(e => console.error(e));

  mainWindowState.manage(win);
}

app.on('ready', createWindow);

let me try to reproduce it as well in a minimal setting, my code base isnt big yet, so maybe you can check it in there if you want with the public repository (let me first clean up the code quickly)

for now this is the code, i didn't have time for the minimal version yet:
https://github.com/mithom/streamerbuddy/blob/feature/auto-update/main.js

this is the error stacktrace:
http://prntscr.com/npjdxn

{ Error: ERR_ABORTED (-3) loading 'http://localhost:50298/'
at rejectAndCleanup (C:\Users\AIR41604\Desktop\Thomas Michiels\streamer-buddy\node_modules\electron\dist\resources\electron.asar\browser\navigation-controller.js:72:21)
at WebContents.navigationListener (C:\Users\AIR41604\Desktop\Thomas Michiels\streamer-buddy\node_modules\electron\dist\resources\electron.asar\browser\navigation-controller.js:93:20)
at WebContents.emit (events.js:194:13)
at WebContents.EventEmitter.emit (domain.js:469:20)
at WebContents.topLevelDomainCallback (domain.js:124:23)

errno: -3,
code: 'ERR_ABORTED',
url: 'http://localhost:50298/' }

i should have tested this before making this issue, but with google it indeed works fine.
I will investigate my issue more, but for now i wouldn't say it is electron-window-state causing causing it anymore. My appologies for looking in the wrong place (initially the error disappeared when i commented the .manage(win) out, but now even that doesn't work)