Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Do not cache stdout or stderr when there is no callback #4267

Closed
wants to merge 1 commit into from

3 participants

@renorzr

Sometimes we need to stream output of exec, there could be large amount of data. We use "event" instead of "callback" on this situation, but still limited by cache of stdout.

@bnoordhuis

Can you explain the purpose of this PR to me? The callback is not optional according to the documentation and though we don't enforce that right now, that's how you should treat it. Not passing in a callback is a bug in your application.

Is the idea to create a version of child_process.spawn() that runs your command in a shell?

@Nodejs-Jenkins

Can one of the admins verify this patch?

@renorzr

@bnoordhuis is right, this is not needed since there is already child_process.spawn. closed.

@renorzr renorzr closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 14 deletions.
  1. +16 −14 lib/child_process.js
View
30 lib/child_process.js
@@ -586,21 +586,23 @@ exports.execFile = function(file /* args, options, callback */) {
child.stdout.setEncoding(options.encoding);
child.stderr.setEncoding(options.encoding);
- child.stdout.addListener('data', function(chunk) {
- stdout += chunk;
- if (stdout.length > options.maxBuffer) {
- err = new Error('stdout maxBuffer exceeded.');
- kill();
- }
- });
+ if (callback) {
+ child.stdout.addListener('data', function(chunk) {
+ stdout += chunk;
+ if (stdout.length > options.maxBuffer) {
+ err = new Error('stdout maxBuffer exceeded.');
+ kill();
+ }
+ });
- child.stderr.addListener('data', function(chunk) {
- stderr += chunk;
- if (stderr.length > options.maxBuffer) {
- err = new Error('stderr maxBuffer exceeded.');
- kill();
- }
- });
+ child.stderr.addListener('data', function(chunk) {
+ stderr += chunk;
+ if (stderr.length > options.maxBuffer) {
+ err = new Error('stderr maxBuffer exceeded.');
+ kill();
+ }
+ });
+ }
child.addListener('close', exithandler);
child.addListener('error', errorhandler);
Something went wrong with that request. Please try again.