Closed sojournerc closed 11 years ago
Hey! Could you please provide your grunt config to research the problem?
Exceeding the buffer only happens occasionally, generally depending on the logging level of jetty. Option bg: true for the watch command was blocking and jetty would not run, hence: "cmd: 'grunt watch &\n mvn -Pjetty-run'".
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-bg-shell');
grunt.initConfig({
watch: {
css: {
files: ['**/*.less', '**/*.css', '!target/**/*'],
tasks: ['less']
}
},
less: {
development: {
options: {
paths: ["css"],
dumpLineNumbers: 'mediaquery'
},
files: {
"target/compiled/css/main.css": "src/main/webapp/less/main.less"
}
}
},
// background shell utility
bgShell: {
runMavenWatchLess: {
cmd: 'grunt watch &\n mvn -Pjetty-run'
}
}
});
// default task
grunt.registerTask('default', ['develop']);
grunt.registerTask('develop', ['target','less:development','bgShell:runMavenWatchLess']);
grunt.registerTask('target', 'creates the target directory for less compile', function () {
grunt.file.mkdir('target/compiled/css');
});
};
You can solve the problem setting execOpts: maxBuffer
to NaN
or Infinity
. You can see how it works in source code
In what way is allocating memory forever a solution?
If you want to run a command line tool with lots of output for a long time, for example.
If you want to run a command line tool with a lot of output for a long time — you can't, because you'll run out of memory. While capturing the output of a subprocess can be useful, grunt is frequently used to run server processes, and so the default should be to not crash by discarding output periodically.
That's just the way how child_process.exec
works. You can see how it adds data chunks to buffer here. If you want to run your process forever I need to reimplement 'child_process.execFile' without keeping buffer
@sojournerc @davidmccabe
You can set execOpts.maxBuffer
to false
, 0
, NaN
or Infinite
. But it won't buffer stdout and stderr for done
callback
Fixed in v2.2.0
Thanks for fixing this!
running jetty using bgShell, occasionally the process is killed with the following error:
It would be optimal to have a maxBuffer option to avoid this issue.