Electron (atom shell) window getting closed on its own after some time

1.6k Views Asked by At

Just a plain Hello World application using electron-prebuilt is set up. I run it by npm start command.

Window shows up as expected normally. However it is getting closed on it's own after some time.

In command prompt it is throwing the following warnings before window is getting closed:

WARNING:raw_channel_win.cc(473)] WriteFile: The pipe is being closed. (0xE8)
WARNING:channel.cc(549)] Failed to send message to ack remove remote endpoint (local ID 1, remote ID 1)
WARNING:channel.cc(315)] RawChannel write error

What is causing this issue?

npm version is 1.4.10 & node (via io.js) version is 0.11.13 (Windows 7 x64)

1

There are 1 best solutions below

0
On BEST ANSWER

As @Oztaco stated, in the QuickStart Guide it has the following code sample:

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the javascript object is GCed.
var mainWindow = null;

// This method will be called when Electron has done everything
// initialization and ready for creating browser windows.
app.on('ready', function() {
  // Create the browser window.
  mainWindow = new BrowserWindow({width: 800, height: 600});

  // other code ommited

  // Emitted when the window is closed.
  mainWindow.on('closed', function() {
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    mainWindow = null;
  });
});