Open
Description
NWJS Version : 0.62.0
Operating System : Windows 10
Expected behavior
When the main nw.exe
process is killed, all child processes should also be killed. No nw.exe
processes should continue leaking memory until the system crashes.
Actual behavior
Intermittently, 2-3 nw.exe
processes will remain running after the "main" process is terminated. When this happens, those processes will continue increasing memory usage until the system runs out of memory and begins killing active processes.
How to reproduce
- Put the following files in a directory.
- Run:
node test.js
- Press CTRL+C in the terminal where step 2 was execute.
- Note that the NW.js application will "quit" but sometimes phantom
nw.exe
processes will remain running. - Watch those phantom
nw.exe
processes slowly chew through all available system memory.
package.json
{
"name": "bug",
"main": "bug.html"
}
bug.html
Hello
test.js
const { spawn } = require('child_process');
// Launch NW.js application
const proc = spawn('nw', ['.']);
console.log(`PID of child_process.exec() process: ${proc.pid}`);
// Kill app on CTRL+C
process.on('SIGINT', () => {
process.kill(proc.pid);
process.exit();
})
// Keep alive until NW.js application exits
let quit = false;
const keepAliveCallback = () => {
if (!quit) setTimeout(keepAliveCallback, 500);
};
keepAliveCallback();
proc.stdout.on('data', (data) => {
process.stdout.write(data);
});
proc.stderr.on('data', (data) => {
process.stderr.write(data);
});
proc.on('exit', () => {
quit = true;
});