jgable / gulp-cache

A cache proxy task for Gulp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Usage with jade causes some files to not be compiled

MikaAK opened this issue · comments

I'm using gulp-cache with gulp-jade and for some reason it causes the occasional file to not be created within jade.

The app I'm working on is getting quite large and this only started to happen recently. Even resetting the cache doesn't make the file get created!!!
I've tried not using a key function but that was no help, however If I remove $.cache() it works properly

My gulp task is as such

gulp.task('jade', function() {
  return gulp.src('app/**/*.jade')
    .on('error', shallowError)
    .pipe($.cache($.jade({pretty: true, doctype:'html'}), {key: createKey}))
    .pipe(gulp.dest('.tmp'))
})
var createKey = function(file) {
  return [file.contents.toString('utf8'), file.stat.mtime, file.stat.size].join('')
}

this only started to happen recently

Do you mean your jade task using gulp-cache was working well?

Correct it was working well up till recently my colleagues and I have only begun to notice this. It could also be due to an update as I just recently updated all project deps!

Could you downgrade gulp-cache to v0.2.8 and try again?

We recently published gulp-cache v0.2.9 but AFAIK there is no large difference from v0.2.8.

I downgraded and tried again but I'm still getting the same problem unfortunately

Can we get access to your repo, or could you put together an example repo that reproduces the issue? This helps narrow it down faster.

Yes, the only difference between v0.2.9 and v0.2.8 is a version bump of object-omit and there is no breaking change.

You should also have your createKey function key off the version of the jade plugin so that when you update the jade plugin the previously cached entries are re-run with the new version of it.

Edit: And also a hash of the options you passed so that if you change the options it will re-run.

Good advice @jgable I'll implement something like that.

Unfortunately this is happening on our repo at work so I can't give access.
It keeps happening but randomly and after cutting saving then pasting and saving the contents of the jade file it no longer occurs on that specific file. When it happens to another file I'll post back and see If I can update with more info. Unfortunately I have yet to be able to reproduce this bug on purpose!

I think I have a repro case for this (no gulp-jade though, Might be a different issue?)

  1. Clone https://github.com/Slayer95/Pokemon-Showdown/tree/gulp-cache (specific branch)
  2. npm install
  3. gulp fastlint. It should fail.
  4. Comment out this line: https://github.com/Slayer95/Pokemon-Showdown/blob/gulp-cache/dev-tools/jscs-custom-rules/validate-case-indentation.js#L73
  5. gulp fastlint. It should succeed.
  6. Revert step 4.
  7. gulp fastlint. It passes!!
  8. gulp clear.
  9. gulp fastlint. It passes again!!!!

EDIT:

At the time of first commenting, glob was absent from package.json. It should be installed as well.

Currently, the ways I have found to make it fail afterwards are
a) Delete the file 188f6c9658410bc249eb5410b2ac778c(*) in the gulp-cache folder (why isn't this done in cache.clearAll?). But if I run gulp fastlint twice it fails (this file is recreated!)
b) Change anything else in the app.js or validate-case-indentation.js files. or any of the other files factored in the key.

(*) keyHash displayed in the console for Step 5.

I'm a little busy tonight with family shenanigans and a date night. I'll
probably have some time this weekend to take a closer look. I have a
suspicion it has to do with the way the key is generated for that .js file.
On Fri, Jun 12, 2015 at 1:53 PM Slayer95 notifications@github.com wrote:

I think I have a repro case for this (no gulp-jade though, Might be a
different issue?)

  1. Clone https://github.com/Slayer95/Pokemon-Showdown/tree/gulp-cache
  2. npm install
  3. gulp. It should fail.
  4. Comment out this line:
    https://github.com/Slayer95/Pokemon-Showdown/blob/gulp-cache/dev-tools/jscs-custom-rules/validate-case-indentation.js#L73
  5. Run gulp again. It should succeed.
  6. Revert step 4.
  7. Run gulp again. It passes!
  8. Run gulp clear.
  9. Run gulp once more. It passes again!!


Reply to this email directly or view it on GitHub
#44 (comment).

And thank you for the detailed steps and a repro repo branch.
On Fri, Jun 12, 2015 at 4:50 PM Jacob Gable jacob.gable@gmail.com wrote:

I'm a little busy tonight with family shenanigans and a date night. I'll
probably have some time this weekend to take a closer look. I have a
suspicion it has to do with the way the key is generated for that .js file.
On Fri, Jun 12, 2015 at 1:53 PM Slayer95 notifications@github.com wrote:

I think I have a repro case for this (no gulp-jade though, Might be a
different issue?)

  1. Clone https://github.com/Slayer95/Pokemon-Showdown/tree/gulp-cache
  2. npm install
  3. gulp. It should fail.
  4. Comment out this line:
    https://github.com/Slayer95/Pokemon-Showdown/blob/gulp-cache/dev-tools/jscs-custom-rules/validate-case-indentation.js#L73
  5. Run gulp again. It should succeed.
  6. Revert step 4.
  7. Run gulp again. It passes!
  8. Run gulp clear.
  9. Run gulp once more. It passes again!!


Reply to this email directly or view it on GitHub
#44 (comment).

Any progress in this, @jgable ?
Would you like a more simplified test case?

I took a look this morning, but gulp fastlint always fails for me. Looks like a lot of naked if statements without { ... } around the conditional body. Can you try running through your steps with a fresh clone, or try npm update to get the latest dependencies?

I tried to dig in a little deeper manually by spitting out the keyHash in your key function, and it looks like the hash of the file changes when any of those dev-tools/** files changes as you'd expect, which would make them run again.

The gulpCache.clearAll doesn't clear your fileCache because you're using a custom one and we have no reference to it in clearAll. I could update that function to take options and allow you to pass a custom fileCache, or you could just run fileCache.clear on your own custom one. When you go with a custom fileCache you kind of have to go all the way of managing it yourself.

Closing this since I haven't heard back in a while.