You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use gulp-foreach to modify the name of asset names in a set of css sheets by this way:
.pipe($.foreach(function(stream, file){
var fileName = path.basename(file.path, '.css');
var assetsManifest = JSON.parse(fs.readFileSync(dest.dist.manifest + "images-manifest.json", 'utf-8'));
_.each(assetsManifest, function (n, key) {
// this line produce the memory leak warning
stream.pipe($.replace(key, n))
})
return stream
.pipe($.minifyCss())
.pipe($.size({
title: fileName + '.min.css size: '
}))
.pipe(gulp.dest(dest.dist.styles))
.pipe($.gzip())
.pipe($.size({
title: fileName + '.min.css.gz size: '
}))
.pipe(gulp.dest(dest.dist.styles));
}))
This is the console log:
(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at Readable.EventEmitter.addListener (events.js:160:15)
at Readable.on (_stream_readable.js:689:33)
at Readable.EventEmitter.once (events.js:185:8)
at Readable.pipe (_stream_readable.js:474:9)
at /home/.../gulpfile.js:283:23
What is $.replace, and why are you piping into it without using the result? It looks like you are mutating the contents of the file objects in place, which is not a good idea (always assume that the stuff you are sending down the stream is immutable and being copied from one pipe to the next).
Instead of foreaching outside the stream.pipe, why not try to foreach inside the pipe(...)? That way you don't fork the stream multiple times. You could use gulp-map for that. For example:
I use gulp-foreach to modify the name of asset names in a set of css sheets by this way:
This is the console log:
There's a lot of npm modules whit this issue. This is probably a node.js bug.
More info
http://stackoverflow.com/a/16222062
nodejs/node-v0.x-archive#5108
If you have a workaround let us know. When I have some time, I will try to fix it and make a PR.
Greetings!
The text was updated successfully, but these errors were encountered: