question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Spawned child process fails due to stdout & stderr filling up with no way to read from parent

See original GitHub issue

Please 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:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
rogerwangcommented, Jan 30, 2018

This is fixed in git and will be available in the next nightly build.

0reactions
jobeninccommented, Jan 31, 2018

That worked for my original issue. Thank you for addressing it so quickly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with stdout and stdin of a child process in Node.js
In this blog post, we run shell commands as child processes in Node.js. We then use async language features to read the stdouts...
Read more >
NodeJS: Send message to persistent child process's stdin ...
My initial attempt is to allow user to enter message from parent process' stdin, and pipe it through its child process. This works...
Read more >
Spawn child process with stdout & stderr going to the same file
I want to spawn a child process and have *all* output go to the same file. ... provides the same FD for both...
Read more >
Multitasking in Node.js With Child Process
There are essentially 3 functions in the child process module that'll help us create child processes. - Spawn - Exec & ExecFile -...
Read more >
subprocess — Subprocess management — Python 3.11.1 ...
The subprocess module allows you to spawn new processes, connect to their ... due to any of the other OS pipe buffers filling...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found