I’m working on adding caching support via a custom plug-in to the netlify build. I have two builds in a row that have hung at the same place:
The hang seems to occur if I try to list the files that have been cached after performing the cacheing. Here’s the important bits of the plug-in:
module.exports = {
async onPreBuild({ constants, utils }) {
const cacheDirs = getCacheDirs(constants);
console.log('Cache directories:', cacheDirs);
const files = await utils.cache.list();
console.log('Netlify cache list', files);
if (await utils.cache.restore(cacheDirs)) {
console.log('Tock build cache found -- using cache.');
} else {
console.warn('No cache found.');
}
},
async onPostBuild({ constants, utils }) {
const cacheDirs = getCacheDirs(constants);
console.log('Cache directories:', cacheDirs);
if (await utils.cache.save(cacheDirs)) {
console.log('Stored Tock build cache.');
} else {
console.error('Failed to save cache.');
}
const files = await utils.cache.list();
console.log('Netlify cache list', files);
},
}
The “print cache” logic works correctly before the attempt to restore in the PreBuild, but hangs in the PostBuild:
4:45:12 PM: Cache directories: [ '/opt/buildhome/.cargo', 'target' ]
4:45:12 PM: Netlify cache list []
4:45:12 PM: No cache found.
...
4:46:53 PM: Cache directories: [ '/opt/buildhome/.cargo', 'target' ]
4:47:00 PM: Stored Tock build cache.
<hang>
The full plug-in code that is running is in this PR: netlify: try cacheing the build if we can by ppannuto · Pull Request #1875 · tock/tock · GitHub