gulp-run icon indicating copy to clipboard operation
gulp-run copied to clipboard

run task hangs if output is too large

Open phazei opened this issue 9 years ago • 3 comments

If a run task outputs too much data to stdout, it seems to hang with no notices or messages or anything.

Originally I thought it was related to maxBuffer, but it seems childProcess.spawn doesn't use that, so it shouldn't have issues itself.

Here is a test case that will replicate it:

Start with running "gulp test"

var
    childProcess = require('child_process'),
    gulp = require('gulp'),
    run = require('gulp-run');

gulp.task('test', function(done){
    var cmd = "gulp test-long";

    //This hangs rather quickly (usually at i=49
    run(cmd,{
        verbosity:3
    }).exec();

    //This never dies
    /*
    var subshell = childProcess.spawn('sh', [
        '-c', cmd
    ], {env: process.env});
    subshell.stdout.pipe(process.stdout);
    subshell.stderr.pipe(process.stderr);
    subshell.stderr.pipe(process.stderr);
    subshell.once('close', function (code) {
        //this is never called
        console.log('PROCESS PROPERLY ENDED');
    });
    //*/
});

gulp.task('test-long', function(done){
    var i = 0;
    setInterval(function() {
        //The longer this is, the sooner it dies.
        console.log("LOTS OF STUFF: " + i++);
        console.log("--------------------------------------------------------------------------------------------------------------------------------");
        console.log("--------------------------------------------------------------------------------------------------------------------------------");
        console.log("--------------------------------------------------------------------------------------------------------------------------------");
        console.log("--------------------------------------------------------------------------------------------------------------------------------");
        console.log("--------------------------------------------------------------------------------------------------------------------------------");
    }, 100);
});

I originally reported it incorrectly in #32

phazei avatar Jul 24 '15 22:07 phazei

I've been fighting the exact same problem for a few hours now. I'm still far from being able to identify the root cause.

louisremi avatar Jul 26 '15 21:07 louisremi

I have the same problem. I run "return run('git -C .docs add --all').exec();" - the git command which supposed to commit all changes. If the amount of changed files is huge and output contains a lot of strings than it just hang and discontinue.

vtkalek avatar Aug 24 '15 19:08 vtkalek

Currently appending > /dev/null to commands to get around this (that's if you don't need the output).

damonmaria avatar May 16 '17 12:05 damonmaria