Skip to content

Commit

Permalink
Make archives deterministic
Browse files Browse the repository at this point in the history
This is similar to:

happo/happo.io#292

I believe that we want to set statConcurrency to 1 here so that the
files in the archives end up in the same order every time (assuming the
glob itself is deterministically ordered).

I am updating happo.io at the same time since it brings the same new
version of archiver as well.
  • Loading branch information
lencioni committed Aug 15, 2024
1 parent 0865674 commit cd1d2b2
Show file tree
Hide file tree
Showing 3 changed files with 333 additions and 496 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
"browserify": "^17.0.0",
"eslint": "^8.2.0",
"eslint-config-prettier": "^9.1.0",
"happo.io": "^6.8.0",
"happo.io": "^10.1.2",
"jsdom": "^20.0.1",
"prettier": "^3.3.3",
"serve-handler": "^6.1.5"
},
"dependencies": {
"archiver": "^5.3.0",
"archiver": "^7.0.1",
"base64-stream": "^1.0.0",
"crypto-js": "^4.1.1",
"https-proxy-agent": "^5.0.0",
Expand Down
6 changes: 5 additions & 1 deletion src/createAssetPackage.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ module.exports = function createAssetPackage(urls) {
// eslint-disable-next-line no-async-promise-executor
return new Promise(async (resolve, reject) => {
const seenUrls = new Set();
const archive = new Archiver('zip');
const archive = new Archiver('zip', {
// Concurrency in the stat queue leads to non-deterministic output.
// https://github.com/archiverjs/node-archiver/issues/383#issuecomment-2253139948
statConcurrency: 1,
});
archive.on('error', (e) => reject(e));

// Create an in-memory stream
Expand Down
Loading

0 comments on commit cd1d2b2

Please sign in to comment.