Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 33cc986

Browse files
fix(cache): reset corrupted caches (mzgoddard#375)
1 parent 3a924aa commit 33cc986

File tree

6 files changed

+51
-3
lines changed

6 files changed

+51
-3
lines changed

‎index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,15 @@ class HardSourceWebpackPlugin {
356356
contextNormalModuleId,
357357
copyWithDeser,
358358
}),
359-
]).then(() => {
360-
// console.log('cache in', Date.now() - start);
361-
});
359+
])
360+
.catch(error => {
361+
logMessages.serialBadCache(compiler, error);
362+
363+
return rimraf(cacheDirPath);
364+
})
365+
.then(() => {
366+
// console.log('cache in', Date.now() - start);
367+
});
362368
});
363369
}
364370

‎lib/util/log-messages.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ exports.cacheNoParity = (compiler, { parityRoot }) => {
4343
);
4444
};
4545

46+
exports.serialBadCache = (compiler, error) => {
47+
const loggerSerial = new LoggerFactory(compiler).create().from('serial');
48+
loggerSerial.error(
49+
{
50+
id: 'serialzation--bad-cache',
51+
},
52+
['Cache is corrupted.', error.stack || error.message || error].join('\n'),
53+
);
54+
};
55+
4656
const logCore = compiler => new LoggerFactory(compiler).create().from('core');
4757

4858
exports.configHashSetButNotUsed = (compiler, { cacheDirectory }) => {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = function(n) {
2+
return n + (n > 0 ? n - 1 : 0);
3+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var fib = require('./fib');
2+
3+
console.log(fib(3));
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var HardSourceWebpackPlugin = require('../../..');
2+
var SerializerAppend2Plugin = require('../../../lib/SerializerAppend2Plugin');
3+
4+
module.exports = {
5+
context: __dirname,
6+
entry: './index.js',
7+
output: {
8+
path: __dirname + '/tmp',
9+
filename: 'main.js',
10+
},
11+
plugins: [
12+
new HardSourceWebpackPlugin({
13+
cacheDirectory: 'cache',
14+
environmentHash: {
15+
root: __dirname + '/../../..',
16+
},
17+
}),
18+
new SerializerAppend2Plugin(),
19+
],
20+
};

‎tests/serializers.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,10 @@ describe('hard source serializers - serializer abilities', function() {
136136
});
137137
});
138138

139+
itCompilesChange('serializer-append-2-base-1dep-bad-cache', {}, {
140+
'tmp/cache/module/log0000': '',
141+
}, function(output) {
142+
expect(output.run2).to.eql(output.run2);
143+
});
144+
139145
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /