Skip to content

[0.31.0] forking with --debug from renderer closes streams instantly #2562

@bpasero

Description

@bpasero

Trying out 0.31.0 I see an issue where my forked app (from the renderer) is quitting instantly as soon as I set its execArgv to --debug to be able to debug it. I verified that this does not happen in an earlier version of Electron (0.27.1):

main.js

var app = require('app');  // Module to control application life.
var BrowserWindow = require('browser-window');  // Module to create native browser window.

// Report crashes to our server.
require('crash-reporter').start();

// 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 amainWindow = null;

// Quit when all windows are closed.
app.on('window-all-closed', function() {
  if (process.platform != 'darwin')
    app.quit();
});

// This method will be called when Eolectron 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, show: true});

  // and load the index.html of the app.
  mainWindow.loadUrl('file://' + __dirname + '/index.html');

  // Open the devtools.
  mainWindow.openDevTools();

  // 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;
  });
});

index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Hello World!</title>
    <script src="./index.js">
    </script>
  </head>
  <body>

  </body>
</html>

index.js

var cp = require("child_process");
var child = cp.fork(__dirname + "/app.js", [], {
  execArgv: ['--debug']
});

child.on('message', function (m) {
  console.log('[PARENT] got message:', m);
});

child.on('close', function () {
  console.log("CLOSED")
})

child.on('exit', function () {
  console.log("EXIT")
})

app.js

process.on("message", function() {

})

The fact that app.js has a listener installed should let it keep running, but instead it closes.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions