From c453624a57ed3b191a5b58c73d97f41f6647c8a7 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 13 Jan 2021 20:37:45 +0100 Subject: [PATCH] store build deps correctly in cache improve debug logging for snapshotting --- lib/FileSystemInfo.js | 21 +++++++++++++-------- lib/cache/PackFileCacheStrategy.js | 10 +++++----- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/lib/FileSystemInfo.js b/lib/FileSystemInfo.js index 8e6733315c4..16d894df29c 100644 --- a/lib/FileSystemInfo.js +++ b/lib/FileSystemInfo.js @@ -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(); @@ -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(); @@ -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(); @@ -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(); @@ -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(); @@ -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(); @@ -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(); @@ -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(); @@ -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); } diff --git a/lib/cache/PackFileCacheStrategy.js b/lib/cache/PackFileCacheStrategy.js index 42fefdf7d25..de9444bd8a3 100644 --- a/lib/cache/PackFileCacheStrategy.js +++ b/lib/cache/PackFileCacheStrategy.js @@ -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`,