Spawned child process fails due to stdout & stderr filling up with no way to read from parent
See original GitHub issuePlease post a workaround if one is known. Thanks!
NWJS Version : 0.27.4 Node Version : 9.3.0 Operating System : Windows 7
Expected behavior
Message traffic between parent and spawned child should continue uninterrupted
Verified expected behavior with - NWJS Version : 0.19.4, Node Version : 7.2.0
Actual behavior
The spawned child process exits with error code: 3221225477
Sub problems:
- maxBuffer config parameter does not appear to change the buffer size for spawn or fork
- Unable to consume stdout or stderr on the parent side
- The more that spawned processes that leverage third party products that print to stdout, the faster the error occurs
How to reproduce
Run the following code with a helloWorld.html of your choice.
package.json
{ "name": "scratch", "version": "0.0.1", "main": "index.js" }
index.js
` const path = require(‘path’); const gui = require(‘nw.gui’); const spawn = require(‘child_process’).spawn;
gui.Window.open(‘helloWorld.html’, {}, function(win) {});
//Create spawned process var child = spawn(process.execPath, [‘./child.js’], { stdio: [‘pipe’, ‘pipe’, ‘pipe’, ‘ipc’], execPath: process.execPath });
//Message sent back from child child.on(‘message’, function(m) { console.log('[Child message] ’ + m.msg); });
//Continually send messages to child (simulates typical IPC traffic) setInterval(function() { console.log(‘ping’) child.send(‘ping’); }, 50);
process.on(‘uncaughtException’, function (err) { console.error(err); }); `
child.js
` //Respond to pings with pongs process.on(‘message’, function(m) { setTimeout(function() { //Add a little bit of print litter to stdout to speed up the errors
process.stdout.write(‘stdout111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111’); process.send({msg: ‘pong’}); }); }); `
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:8 (4 by maintainers)
Top GitHub Comments
This is fixed in git and will be available in the next nightly build.
That worked for my original issue. Thank you for addressing it so quickly.