Skip to content

Commit

Permalink
store build deps correctly in cache
Browse files Browse the repository at this point in the history
improve debug logging for snapshotting
  • Loading branch information
sokra committed Jan 13, 2021
1 parent 10cb9ec commit 1bbb52d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
21 changes: 13 additions & 8 deletions lib/FileSystemInfo.js
Expand Up @@ -1606,7 +1606,7 @@ class FileSystemInfo {
if (err) {
if (this.logger) {
this.logger.debug(
`Error snapshotting file timestamp hash combination of ${path}: ${err}`
`Error snapshotting file timestamp hash combination of ${path}: ${err.stack}`
);
}
jobError();
Expand Down Expand Up @@ -1634,7 +1634,7 @@ class FileSystemInfo {
if (err) {
if (this.logger) {
this.logger.debug(
`Error snapshotting file hash of ${path}: ${err}`
`Error snapshotting file hash of ${path}: ${err.stack}`
);
}
jobError();
Expand Down Expand Up @@ -1664,7 +1664,7 @@ class FileSystemInfo {
if (err) {
if (this.logger) {
this.logger.debug(
`Error snapshotting file timestamp of ${path}: ${err}`
`Error snapshotting file timestamp of ${path}: ${err.stack}`
);
}
jobError();
Expand Down Expand Up @@ -1700,7 +1700,7 @@ class FileSystemInfo {
if (err) {
if (this.logger) {
this.logger.debug(
`Error snapshotting context timestamp hash combination of ${path}: ${err}`
`Error snapshotting context timestamp hash combination of ${path}: ${err.stack}`
);
}
jobError();
Expand Down Expand Up @@ -1728,7 +1728,7 @@ class FileSystemInfo {
if (err) {
if (this.logger) {
this.logger.debug(
`Error snapshotting context hash of ${path}: ${err}`
`Error snapshotting context hash of ${path}: ${err.stack}`
);
}
jobError();
Expand Down Expand Up @@ -1758,7 +1758,7 @@ class FileSystemInfo {
if (err) {
if (this.logger) {
this.logger.debug(
`Error snapshotting context timestamp of ${path}: ${err}`
`Error snapshotting context timestamp of ${path}: ${err.stack}`
);
}
jobError();
Expand Down Expand Up @@ -1791,7 +1791,7 @@ class FileSystemInfo {
if (err) {
if (this.logger) {
this.logger.debug(
`Error snapshotting missing timestamp of ${path}: ${err}`
`Error snapshotting missing timestamp of ${path}: ${err.stack}`
);
}
jobError();
Expand All @@ -1818,7 +1818,7 @@ class FileSystemInfo {
if (err) {
if (this.logger) {
this.logger.debug(
`Error snapshotting managed item ${path}: ${err}`
`Error snapshotting managed item ${path}: ${err.stack}`
);
}
jobError();
Expand Down Expand Up @@ -2348,6 +2348,11 @@ class FileSystemInfo {
this._fileHashes.set(path, null);
return callback(null, null);
}
if (err.code === "ERR_FS_FILE_TOO_LARGE") {
this.logger.warn(`Ignoring ${path} for hashing as it's very large`);
this._fileHashes.set(path, "too large");
return callback(null, "too large");
}
return callback(err);
}

Expand Down
10 changes: 5 additions & 5 deletions lib/cache/PackFileCacheStrategy.js
Expand Up @@ -1072,18 +1072,18 @@ class PackFileCacheStrategy {
return promise.then(() => {
if (reportProgress) reportProgress(0.8, "serialize pack");
this.logger.time(`store pack`);
const updatedBuildDependencies = new Set(this.buildDependencies);
for (const dep of newBuildDependencies) {
updatedBuildDependencies.add(dep);
}
const content = new PackContainer(
pack,
this.version,
this.buildSnapshot,
this.buildDependencies,
updatedBuildDependencies,
this.resolveResults,
this.resolveBuildDependenciesSnapshot
);
// You might think this breaks all access to the existing pack
// which are still referenced, but serializing the pack memorizes
// all data in the pack and makes it no longer need the backing file
// So it's safe to replace the pack file
return this.fileSerializer
.serialize(content, {
filename: `${this.cacheLocation}/index.pack`,
Expand Down

0 comments on commit 1bbb52d

Please sign in to comment.