-
-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Node memory leak running assemble #936
Comments
@bitdepth Thanks for the issue! If you're reporting a bug, please be sure to include:
If your issue is related to one of the following, please open an issue there:
|
@bitdepth if you add me to the repo, I'll take a look when I have a chance. |
It's most likely not an assemble bug. As with the other issue that you commented on, it's most likely caused by something you're doing wrong, like merging data with cyclical references (most likely in a helper). If you've narrowed it down to the partials, then you should be able to narrow it down to a specific partial by eliminating them one at a time, or by replacing the contents of each partial with an empty string. This is what @doowb or I would end up doing first. After that, if the problem still persists and we're not able to find a user error, we'll dig deeper in assemble's code (or more likely the code of a helper) to figure out where the bug is. |
you probably should not be reloading helpers every time edit: does the problem persist after removing watch? |
I've had the same issue with memory leaks while running assemble in a watch task - it appears to be a problem with Handlebars rather than assemble from what I could tell, but I couldn't get a definitive answer of where the problem lies. My solution was to use gulp-cached before calling assemble.renderFile() assemble.task('html.build', function(){
return assemble.toStream('pages')
.pipe(cache('html.build'))
.pipe(assemble.renderFile())
.pipe(rename({ extname:'.html' }))
.pipe(assemble.dest('dist/html'));
}); Then modify the watch task, this has to be done because you need to bust the cache when any partials or data files are changed. assemble.task('watch', function(){
assemble.watch([
'src/**/*.hbs',
'src/**/data/*.json'
], [
'html'
], function(done){
browserSync.reload();
done();
}).on('change', function(file) {
// NOTE: gulp-cached keeps a copy of the handlebars page, but not the partials or data files
// So when these files are modified, gulp-cached just skips over them and no changes are reflected
// This callback function was created to remove the relevant page from the cache if any of the
// partials or data files are modified
var directory = path.dirname(file).split(path.sep);
var folder = directory.pop();
var paths = ['data', 'partials'];
var cacheBust = false;
paths.forEach(function(path) {
if (folder === path) {
cacheBust = true;
}
});
// Check the key exists in the cache first
if (cache.caches['html.build'] && cacheBust) {
for (var key in cache.caches['html.build']) {
var cacheFolder = path.dirname(key);
var parentPath = directory.join(path.sep);
// Paths match, so delete it from the folder
// We also need to remove any global pages from the cache
if (cacheFolder.endsWith(parentPath) || cacheFolder.endsWith('html')) {
delete cache.caches['html.build'][key];
}
}
}
}); Not ideal, but our watch tasks really fly now. |
That's similar to what I was thinking. My hunch is that it's a combination of helper binding and watch, or something similar that is causing a memory leak. I'm going to look into this as soon as I get some free time in the next few days. |
Hey @jonschlinkert, we are experiencing a very similar issue to #871 at the moment and our team are also considering porting to another static site generator.
Version
assemble 0.24.3
withbase-watch 0.1.3
node 8.2.1
Description
Adding content to the partials and pages causes the build time to grow until eventually node runs out of memory and the build falls over.
Error Message
assemblefile.js
I have gone through some of the suggestions in this #871 and the build runs fine until i add the partials directory so i believe the error is caused by some combination of the data and the partials working together.
I have isolated the assemble stuff and added it to a private repo which i can share with you.
The text was updated successfully, but these errors were encountered: