Electron event emitter error while app.quit with closing all open renderer processes












0















I have one main window listing all available servers with a status button which has the id of the server. An info window is opened after pressing the related status button - passing the id to the copy of info window, making the status button disabled. If the info window is closed, the info window passes back the id to the main window so it makes the status button enabled again. To do that, I'm using main.js as a proxy, listening to the renderer processes and exchange information between main window and info window.



The thing that I'm trying to do is to list servers. If they are online, get some information from multiple servers at once on different renderer processes (instance of info window).



The problem is I want all info windows to be closed if the main window is closed.



// App ready
app.on('ready', ()=>{
mainWindow = new BrowserWindow({x : 0, y : 0 , width : 500, height: 600});

mainWindow.loadURL(url.format({
pathname : path.join(__dirname, 'windows', 'mainWindow.html'),
protocol : 'file',
slashes : true
}));

// Close the app if main window closed
mainWindow.on('close', (e) => {
let openedOnes = BrowserWindow.getAllWindows();
openedOnes.forEach(wind => {
if(wind.hasOwnProperty('custom')){
wind.close();
};
});

app.quit();
});
});


While creating info window, I add a custom field to the BrowserWindow object:



BrowserWindow {
_events:
{ blur: [Function],
focus: [Function],
show: [Function: visibilityChanged],
hide: [Function: visibilityChanged],
minimize: [Function: visibilityChanged],
maximize: [Function: visibilityChanged],
restore: [Function: visibilityChanged],
close: [Function: callIntoRenderer] },
_eventsCount: 8,
devToolsWebContents: [Getter],
custom: { server_id: '3' } }


So with the help of the custom field, I can get all opened server info instances.



But when I click close, the following part is failing at main.js;



ipcMain.on('window_closed', (e, item)=>{
mainWindow.webContents.send('button_enable', item);
});


It raises the following error.



enter image description here



main.js:53 is the line ipcMain.on('window_closed'.... By the way, if I omit this line everything works perfectly.










share|improve this question





























    0















    I have one main window listing all available servers with a status button which has the id of the server. An info window is opened after pressing the related status button - passing the id to the copy of info window, making the status button disabled. If the info window is closed, the info window passes back the id to the main window so it makes the status button enabled again. To do that, I'm using main.js as a proxy, listening to the renderer processes and exchange information between main window and info window.



    The thing that I'm trying to do is to list servers. If they are online, get some information from multiple servers at once on different renderer processes (instance of info window).



    The problem is I want all info windows to be closed if the main window is closed.



    // App ready
    app.on('ready', ()=>{
    mainWindow = new BrowserWindow({x : 0, y : 0 , width : 500, height: 600});

    mainWindow.loadURL(url.format({
    pathname : path.join(__dirname, 'windows', 'mainWindow.html'),
    protocol : 'file',
    slashes : true
    }));

    // Close the app if main window closed
    mainWindow.on('close', (e) => {
    let openedOnes = BrowserWindow.getAllWindows();
    openedOnes.forEach(wind => {
    if(wind.hasOwnProperty('custom')){
    wind.close();
    };
    });

    app.quit();
    });
    });


    While creating info window, I add a custom field to the BrowserWindow object:



    BrowserWindow {
    _events:
    { blur: [Function],
    focus: [Function],
    show: [Function: visibilityChanged],
    hide: [Function: visibilityChanged],
    minimize: [Function: visibilityChanged],
    maximize: [Function: visibilityChanged],
    restore: [Function: visibilityChanged],
    close: [Function: callIntoRenderer] },
    _eventsCount: 8,
    devToolsWebContents: [Getter],
    custom: { server_id: '3' } }


    So with the help of the custom field, I can get all opened server info instances.



    But when I click close, the following part is failing at main.js;



    ipcMain.on('window_closed', (e, item)=>{
    mainWindow.webContents.send('button_enable', item);
    });


    It raises the following error.



    enter image description here



    main.js:53 is the line ipcMain.on('window_closed'.... By the way, if I omit this line everything works perfectly.










    share|improve this question



























      0












      0








      0








      I have one main window listing all available servers with a status button which has the id of the server. An info window is opened after pressing the related status button - passing the id to the copy of info window, making the status button disabled. If the info window is closed, the info window passes back the id to the main window so it makes the status button enabled again. To do that, I'm using main.js as a proxy, listening to the renderer processes and exchange information between main window and info window.



      The thing that I'm trying to do is to list servers. If they are online, get some information from multiple servers at once on different renderer processes (instance of info window).



      The problem is I want all info windows to be closed if the main window is closed.



      // App ready
      app.on('ready', ()=>{
      mainWindow = new BrowserWindow({x : 0, y : 0 , width : 500, height: 600});

      mainWindow.loadURL(url.format({
      pathname : path.join(__dirname, 'windows', 'mainWindow.html'),
      protocol : 'file',
      slashes : true
      }));

      // Close the app if main window closed
      mainWindow.on('close', (e) => {
      let openedOnes = BrowserWindow.getAllWindows();
      openedOnes.forEach(wind => {
      if(wind.hasOwnProperty('custom')){
      wind.close();
      };
      });

      app.quit();
      });
      });


      While creating info window, I add a custom field to the BrowserWindow object:



      BrowserWindow {
      _events:
      { blur: [Function],
      focus: [Function],
      show: [Function: visibilityChanged],
      hide: [Function: visibilityChanged],
      minimize: [Function: visibilityChanged],
      maximize: [Function: visibilityChanged],
      restore: [Function: visibilityChanged],
      close: [Function: callIntoRenderer] },
      _eventsCount: 8,
      devToolsWebContents: [Getter],
      custom: { server_id: '3' } }


      So with the help of the custom field, I can get all opened server info instances.



      But when I click close, the following part is failing at main.js;



      ipcMain.on('window_closed', (e, item)=>{
      mainWindow.webContents.send('button_enable', item);
      });


      It raises the following error.



      enter image description here



      main.js:53 is the line ipcMain.on('window_closed'.... By the way, if I omit this line everything works perfectly.










      share|improve this question
















      I have one main window listing all available servers with a status button which has the id of the server. An info window is opened after pressing the related status button - passing the id to the copy of info window, making the status button disabled. If the info window is closed, the info window passes back the id to the main window so it makes the status button enabled again. To do that, I'm using main.js as a proxy, listening to the renderer processes and exchange information between main window and info window.



      The thing that I'm trying to do is to list servers. If they are online, get some information from multiple servers at once on different renderer processes (instance of info window).



      The problem is I want all info windows to be closed if the main window is closed.



      // App ready
      app.on('ready', ()=>{
      mainWindow = new BrowserWindow({x : 0, y : 0 , width : 500, height: 600});

      mainWindow.loadURL(url.format({
      pathname : path.join(__dirname, 'windows', 'mainWindow.html'),
      protocol : 'file',
      slashes : true
      }));

      // Close the app if main window closed
      mainWindow.on('close', (e) => {
      let openedOnes = BrowserWindow.getAllWindows();
      openedOnes.forEach(wind => {
      if(wind.hasOwnProperty('custom')){
      wind.close();
      };
      });

      app.quit();
      });
      });


      While creating info window, I add a custom field to the BrowserWindow object:



      BrowserWindow {
      _events:
      { blur: [Function],
      focus: [Function],
      show: [Function: visibilityChanged],
      hide: [Function: visibilityChanged],
      minimize: [Function: visibilityChanged],
      maximize: [Function: visibilityChanged],
      restore: [Function: visibilityChanged],
      close: [Function: callIntoRenderer] },
      _eventsCount: 8,
      devToolsWebContents: [Getter],
      custom: { server_id: '3' } }


      So with the help of the custom field, I can get all opened server info instances.



      But when I click close, the following part is failing at main.js;



      ipcMain.on('window_closed', (e, item)=>{
      mainWindow.webContents.send('button_enable', item);
      });


      It raises the following error.



      enter image description here



      main.js:53 is the line ipcMain.on('window_closed'.... By the way, if I omit this line everything works perfectly.







      node.js electron






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 '18 at 22:23









      pushkin

      4,030112752




      4,030112752










      asked Nov 18 '18 at 11:09









      Kerem CavusogluKerem Cavusoglu

      337




      337
























          3 Answers
          3






          active

          oldest

          votes


















          1














          It looks like what's happening is your mainWindow close handler gets triggered which tells other windows to close, which then fires off the window_closed event (I guess that's a custom event that you added?), and by the timemainWindow.webContents.send is called, the mainWindow's close handler finished and the window closed.



          Simply add an isDestroyed check before sending the message like so:



          ipcMain.on('window_closed', (e, item)=>{
          if (mainWindow && !mainWindow.isDestroyed())
          mainWindow.webContents.send('button_enable', item);
          });




          Your other options (though arguably less optimal) are:




          1. Set a flag when the main window is closing and have the window_closed handler return out if it sees the flag (surely there's no reason to send a button_enable message if we're about to shut everything down):


           



          let mainWindowIsClosing = false;
          mainWindow.on('close', (e)=>{
          mainWindowIsClosing = true;
          ...
          wind.close();
          ...
          });

          ipcMain.on('window_closed', (e, item)=>{
          if (mainWindowIsClosing) return;
          mainWindow.webContents.send('button_enable', item);
          });



          1. You can call the destroy method instead of close to avoid firing the close event for child windows. (though window_closed isn't an Electron event I believe, so it depends on how you've hooked everything up):


           



          mainWindow.on('close', (e)=>{
          ...
          wind.destroy();
          });





          share|improve this answer


























          • Thanks for the simple solution. I think isDestroyed chek is the best way to solve that issue. I have tried your solution and it seems everything is ok, thanks again.

            – Kerem Cavusoglu
            Nov 20 '18 at 13:57



















          0














          Found a solution as follows;



          mainWindow.on('close', (e)=>{
          mainWindow = null;
          try{
          let openedOnes = BrowserWindow.getAllWindows();
          openedOnes.forEach(wind=>{
          if(wind.hasOwnProperty('custom')){
          wind.close();
          };
          });

          app.quit();

          }catch(e){
          console.log(e);
          }
          });


          Before closing the main window, i set the mainwindow to null. When an info window is closed, check if its not set to null, send the mainwindow an info window is closed and its status button should be enabled;



          ipcMain.on('window_closed', (e, item)=>{
          try {
          if(mainWindow !== null){
          mainWindow.webContents.send('button_enable', item);
          }
          } catch (error) {
          console.log(error);
          }
          });





          share|improve this answer
























          • I wonder, if you add a closed handler on the mainWindow, does it get triggered after you null it out? Typically, you should null out the window in the closed handler, not close. Your approach might prevent other window events from firing, which isn't ideal. Setting a flag like in my answer is likely more appropriate

            – pushkin
            Nov 19 '18 at 18:15











          • You are right. I have checked the documents again and with closed event we should set the browserwindow object to null not with the close event.

            – Kerem Cavusoglu
            Nov 20 '18 at 13:59



















          0














          You should use Child/Parent BrowserWindows like here: https://electronjs.org/docs/api/browser-window#parent-and-child-windows



          You will get more easier all child windows with:



          win.getChildWindows()


          https://electronjs.org/docs/api/browser-window#wingetchildwindows






          share|improve this answer
























          • Your problem with ipcMain.on('window_closed') is because you catch also your mainWindow close hook

            – Toinane
            Nov 19 '18 at 13:50











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53360169%2felectron-event-emitter-error-while-app-quit-with-closing-all-open-renderer-proce%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          3 Answers
          3






          active

          oldest

          votes








          3 Answers
          3






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          It looks like what's happening is your mainWindow close handler gets triggered which tells other windows to close, which then fires off the window_closed event (I guess that's a custom event that you added?), and by the timemainWindow.webContents.send is called, the mainWindow's close handler finished and the window closed.



          Simply add an isDestroyed check before sending the message like so:



          ipcMain.on('window_closed', (e, item)=>{
          if (mainWindow && !mainWindow.isDestroyed())
          mainWindow.webContents.send('button_enable', item);
          });




          Your other options (though arguably less optimal) are:




          1. Set a flag when the main window is closing and have the window_closed handler return out if it sees the flag (surely there's no reason to send a button_enable message if we're about to shut everything down):


           



          let mainWindowIsClosing = false;
          mainWindow.on('close', (e)=>{
          mainWindowIsClosing = true;
          ...
          wind.close();
          ...
          });

          ipcMain.on('window_closed', (e, item)=>{
          if (mainWindowIsClosing) return;
          mainWindow.webContents.send('button_enable', item);
          });



          1. You can call the destroy method instead of close to avoid firing the close event for child windows. (though window_closed isn't an Electron event I believe, so it depends on how you've hooked everything up):


           



          mainWindow.on('close', (e)=>{
          ...
          wind.destroy();
          });





          share|improve this answer


























          • Thanks for the simple solution. I think isDestroyed chek is the best way to solve that issue. I have tried your solution and it seems everything is ok, thanks again.

            – Kerem Cavusoglu
            Nov 20 '18 at 13:57
















          1














          It looks like what's happening is your mainWindow close handler gets triggered which tells other windows to close, which then fires off the window_closed event (I guess that's a custom event that you added?), and by the timemainWindow.webContents.send is called, the mainWindow's close handler finished and the window closed.



          Simply add an isDestroyed check before sending the message like so:



          ipcMain.on('window_closed', (e, item)=>{
          if (mainWindow && !mainWindow.isDestroyed())
          mainWindow.webContents.send('button_enable', item);
          });




          Your other options (though arguably less optimal) are:




          1. Set a flag when the main window is closing and have the window_closed handler return out if it sees the flag (surely there's no reason to send a button_enable message if we're about to shut everything down):


           



          let mainWindowIsClosing = false;
          mainWindow.on('close', (e)=>{
          mainWindowIsClosing = true;
          ...
          wind.close();
          ...
          });

          ipcMain.on('window_closed', (e, item)=>{
          if (mainWindowIsClosing) return;
          mainWindow.webContents.send('button_enable', item);
          });



          1. You can call the destroy method instead of close to avoid firing the close event for child windows. (though window_closed isn't an Electron event I believe, so it depends on how you've hooked everything up):


           



          mainWindow.on('close', (e)=>{
          ...
          wind.destroy();
          });





          share|improve this answer


























          • Thanks for the simple solution. I think isDestroyed chek is the best way to solve that issue. I have tried your solution and it seems everything is ok, thanks again.

            – Kerem Cavusoglu
            Nov 20 '18 at 13:57














          1












          1








          1







          It looks like what's happening is your mainWindow close handler gets triggered which tells other windows to close, which then fires off the window_closed event (I guess that's a custom event that you added?), and by the timemainWindow.webContents.send is called, the mainWindow's close handler finished and the window closed.



          Simply add an isDestroyed check before sending the message like so:



          ipcMain.on('window_closed', (e, item)=>{
          if (mainWindow && !mainWindow.isDestroyed())
          mainWindow.webContents.send('button_enable', item);
          });




          Your other options (though arguably less optimal) are:




          1. Set a flag when the main window is closing and have the window_closed handler return out if it sees the flag (surely there's no reason to send a button_enable message if we're about to shut everything down):


           



          let mainWindowIsClosing = false;
          mainWindow.on('close', (e)=>{
          mainWindowIsClosing = true;
          ...
          wind.close();
          ...
          });

          ipcMain.on('window_closed', (e, item)=>{
          if (mainWindowIsClosing) return;
          mainWindow.webContents.send('button_enable', item);
          });



          1. You can call the destroy method instead of close to avoid firing the close event for child windows. (though window_closed isn't an Electron event I believe, so it depends on how you've hooked everything up):


           



          mainWindow.on('close', (e)=>{
          ...
          wind.destroy();
          });





          share|improve this answer















          It looks like what's happening is your mainWindow close handler gets triggered which tells other windows to close, which then fires off the window_closed event (I guess that's a custom event that you added?), and by the timemainWindow.webContents.send is called, the mainWindow's close handler finished and the window closed.



          Simply add an isDestroyed check before sending the message like so:



          ipcMain.on('window_closed', (e, item)=>{
          if (mainWindow && !mainWindow.isDestroyed())
          mainWindow.webContents.send('button_enable', item);
          });




          Your other options (though arguably less optimal) are:




          1. Set a flag when the main window is closing and have the window_closed handler return out if it sees the flag (surely there's no reason to send a button_enable message if we're about to shut everything down):


           



          let mainWindowIsClosing = false;
          mainWindow.on('close', (e)=>{
          mainWindowIsClosing = true;
          ...
          wind.close();
          ...
          });

          ipcMain.on('window_closed', (e, item)=>{
          if (mainWindowIsClosing) return;
          mainWindow.webContents.send('button_enable', item);
          });



          1. You can call the destroy method instead of close to avoid firing the close event for child windows. (though window_closed isn't an Electron event I believe, so it depends on how you've hooked everything up):


           



          mainWindow.on('close', (e)=>{
          ...
          wind.destroy();
          });






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 19 '18 at 15:46

























          answered Nov 19 '18 at 15:38









          pushkinpushkin

          4,030112752




          4,030112752













          • Thanks for the simple solution. I think isDestroyed chek is the best way to solve that issue. I have tried your solution and it seems everything is ok, thanks again.

            – Kerem Cavusoglu
            Nov 20 '18 at 13:57



















          • Thanks for the simple solution. I think isDestroyed chek is the best way to solve that issue. I have tried your solution and it seems everything is ok, thanks again.

            – Kerem Cavusoglu
            Nov 20 '18 at 13:57

















          Thanks for the simple solution. I think isDestroyed chek is the best way to solve that issue. I have tried your solution and it seems everything is ok, thanks again.

          – Kerem Cavusoglu
          Nov 20 '18 at 13:57





          Thanks for the simple solution. I think isDestroyed chek is the best way to solve that issue. I have tried your solution and it seems everything is ok, thanks again.

          – Kerem Cavusoglu
          Nov 20 '18 at 13:57













          0














          Found a solution as follows;



          mainWindow.on('close', (e)=>{
          mainWindow = null;
          try{
          let openedOnes = BrowserWindow.getAllWindows();
          openedOnes.forEach(wind=>{
          if(wind.hasOwnProperty('custom')){
          wind.close();
          };
          });

          app.quit();

          }catch(e){
          console.log(e);
          }
          });


          Before closing the main window, i set the mainwindow to null. When an info window is closed, check if its not set to null, send the mainwindow an info window is closed and its status button should be enabled;



          ipcMain.on('window_closed', (e, item)=>{
          try {
          if(mainWindow !== null){
          mainWindow.webContents.send('button_enable', item);
          }
          } catch (error) {
          console.log(error);
          }
          });





          share|improve this answer
























          • I wonder, if you add a closed handler on the mainWindow, does it get triggered after you null it out? Typically, you should null out the window in the closed handler, not close. Your approach might prevent other window events from firing, which isn't ideal. Setting a flag like in my answer is likely more appropriate

            – pushkin
            Nov 19 '18 at 18:15











          • You are right. I have checked the documents again and with closed event we should set the browserwindow object to null not with the close event.

            – Kerem Cavusoglu
            Nov 20 '18 at 13:59
















          0














          Found a solution as follows;



          mainWindow.on('close', (e)=>{
          mainWindow = null;
          try{
          let openedOnes = BrowserWindow.getAllWindows();
          openedOnes.forEach(wind=>{
          if(wind.hasOwnProperty('custom')){
          wind.close();
          };
          });

          app.quit();

          }catch(e){
          console.log(e);
          }
          });


          Before closing the main window, i set the mainwindow to null. When an info window is closed, check if its not set to null, send the mainwindow an info window is closed and its status button should be enabled;



          ipcMain.on('window_closed', (e, item)=>{
          try {
          if(mainWindow !== null){
          mainWindow.webContents.send('button_enable', item);
          }
          } catch (error) {
          console.log(error);
          }
          });





          share|improve this answer
























          • I wonder, if you add a closed handler on the mainWindow, does it get triggered after you null it out? Typically, you should null out the window in the closed handler, not close. Your approach might prevent other window events from firing, which isn't ideal. Setting a flag like in my answer is likely more appropriate

            – pushkin
            Nov 19 '18 at 18:15











          • You are right. I have checked the documents again and with closed event we should set the browserwindow object to null not with the close event.

            – Kerem Cavusoglu
            Nov 20 '18 at 13:59














          0












          0








          0







          Found a solution as follows;



          mainWindow.on('close', (e)=>{
          mainWindow = null;
          try{
          let openedOnes = BrowserWindow.getAllWindows();
          openedOnes.forEach(wind=>{
          if(wind.hasOwnProperty('custom')){
          wind.close();
          };
          });

          app.quit();

          }catch(e){
          console.log(e);
          }
          });


          Before closing the main window, i set the mainwindow to null. When an info window is closed, check if its not set to null, send the mainwindow an info window is closed and its status button should be enabled;



          ipcMain.on('window_closed', (e, item)=>{
          try {
          if(mainWindow !== null){
          mainWindow.webContents.send('button_enable', item);
          }
          } catch (error) {
          console.log(error);
          }
          });





          share|improve this answer













          Found a solution as follows;



          mainWindow.on('close', (e)=>{
          mainWindow = null;
          try{
          let openedOnes = BrowserWindow.getAllWindows();
          openedOnes.forEach(wind=>{
          if(wind.hasOwnProperty('custom')){
          wind.close();
          };
          });

          app.quit();

          }catch(e){
          console.log(e);
          }
          });


          Before closing the main window, i set the mainwindow to null. When an info window is closed, check if its not set to null, send the mainwindow an info window is closed and its status button should be enabled;



          ipcMain.on('window_closed', (e, item)=>{
          try {
          if(mainWindow !== null){
          mainWindow.webContents.send('button_enable', item);
          }
          } catch (error) {
          console.log(error);
          }
          });






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 19 '18 at 5:52









          Kerem CavusogluKerem Cavusoglu

          337




          337













          • I wonder, if you add a closed handler on the mainWindow, does it get triggered after you null it out? Typically, you should null out the window in the closed handler, not close. Your approach might prevent other window events from firing, which isn't ideal. Setting a flag like in my answer is likely more appropriate

            – pushkin
            Nov 19 '18 at 18:15











          • You are right. I have checked the documents again and with closed event we should set the browserwindow object to null not with the close event.

            – Kerem Cavusoglu
            Nov 20 '18 at 13:59



















          • I wonder, if you add a closed handler on the mainWindow, does it get triggered after you null it out? Typically, you should null out the window in the closed handler, not close. Your approach might prevent other window events from firing, which isn't ideal. Setting a flag like in my answer is likely more appropriate

            – pushkin
            Nov 19 '18 at 18:15











          • You are right. I have checked the documents again and with closed event we should set the browserwindow object to null not with the close event.

            – Kerem Cavusoglu
            Nov 20 '18 at 13:59

















          I wonder, if you add a closed handler on the mainWindow, does it get triggered after you null it out? Typically, you should null out the window in the closed handler, not close. Your approach might prevent other window events from firing, which isn't ideal. Setting a flag like in my answer is likely more appropriate

          – pushkin
          Nov 19 '18 at 18:15





          I wonder, if you add a closed handler on the mainWindow, does it get triggered after you null it out? Typically, you should null out the window in the closed handler, not close. Your approach might prevent other window events from firing, which isn't ideal. Setting a flag like in my answer is likely more appropriate

          – pushkin
          Nov 19 '18 at 18:15













          You are right. I have checked the documents again and with closed event we should set the browserwindow object to null not with the close event.

          – Kerem Cavusoglu
          Nov 20 '18 at 13:59





          You are right. I have checked the documents again and with closed event we should set the browserwindow object to null not with the close event.

          – Kerem Cavusoglu
          Nov 20 '18 at 13:59











          0














          You should use Child/Parent BrowserWindows like here: https://electronjs.org/docs/api/browser-window#parent-and-child-windows



          You will get more easier all child windows with:



          win.getChildWindows()


          https://electronjs.org/docs/api/browser-window#wingetchildwindows






          share|improve this answer
























          • Your problem with ipcMain.on('window_closed') is because you catch also your mainWindow close hook

            – Toinane
            Nov 19 '18 at 13:50
















          0














          You should use Child/Parent BrowserWindows like here: https://electronjs.org/docs/api/browser-window#parent-and-child-windows



          You will get more easier all child windows with:



          win.getChildWindows()


          https://electronjs.org/docs/api/browser-window#wingetchildwindows






          share|improve this answer
























          • Your problem with ipcMain.on('window_closed') is because you catch also your mainWindow close hook

            – Toinane
            Nov 19 '18 at 13:50














          0












          0








          0







          You should use Child/Parent BrowserWindows like here: https://electronjs.org/docs/api/browser-window#parent-and-child-windows



          You will get more easier all child windows with:



          win.getChildWindows()


          https://electronjs.org/docs/api/browser-window#wingetchildwindows






          share|improve this answer













          You should use Child/Parent BrowserWindows like here: https://electronjs.org/docs/api/browser-window#parent-and-child-windows



          You will get more easier all child windows with:



          win.getChildWindows()


          https://electronjs.org/docs/api/browser-window#wingetchildwindows







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 19 '18 at 13:47









          ToinaneToinane

          214




          214













          • Your problem with ipcMain.on('window_closed') is because you catch also your mainWindow close hook

            – Toinane
            Nov 19 '18 at 13:50



















          • Your problem with ipcMain.on('window_closed') is because you catch also your mainWindow close hook

            – Toinane
            Nov 19 '18 at 13:50

















          Your problem with ipcMain.on('window_closed') is because you catch also your mainWindow close hook

          – Toinane
          Nov 19 '18 at 13:50





          Your problem with ipcMain.on('window_closed') is because you catch also your mainWindow close hook

          – Toinane
          Nov 19 '18 at 13:50


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53360169%2felectron-event-emitter-error-while-app-quit-with-closing-all-open-renderer-proce%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Guess what letter conforming each word

          Port of Spain

          Run scheduled task as local user group (not BUILTIN)