* Resolve context tsh. * @private * @param {ContextTimestampAndHash} entry entry * @param {ProcessorCallback<ResolvedContextTimestampAndHash>} callback callback * @returns {void}
(entry, callback)
| 4308 | * @returns {void} |
| 4309 | */ |
| 4310 | _resolveContextTsh(entry, callback) { |
| 4311 | /** @type {string[]} */ |
| 4312 | const hashes = []; |
| 4313 | /** @type {string[]} */ |
| 4314 | const tsHashes = []; |
| 4315 | let safeTime = 0; |
| 4316 | class="cm">// Skip already-visited symlink targets so cyclic pnpm/peer-variant graphs terminate (#21084). |
| 4317 | const seen = new Set(entry.symlinks); |
| 4318 | processAsyncTree( |
| 4319 | /** @type {NonNullable<ContextHash[class="st">"symlinks"]>} */ (entry.symlinks), |
| 4320 | 10, |
| 4321 | (target, push, callback) => { |
| 4322 | this._getUnresolvedContextTsh(target, (err, entry) => { |
| 4323 | if (err) return callback(err); |
| 4324 | if (entry) { |
| 4325 | hashes.push(entry.hash); |
| 4326 | if (entry.timestampHash) tsHashes.push(entry.timestampHash); |
| 4327 | if (entry.safeTime) { |
| 4328 | safeTime = Math.max(safeTime, entry.safeTime); |
| 4329 | } |
| 4330 | if (entry.symlinks !== undefined) { |
| 4331 | for (const target of entry.symlinks) { |
| 4332 | if (!seen.has(target)) { |
| 4333 | seen.add(target); |
| 4334 | push(target); |
| 4335 | } |
| 4336 | } |
| 4337 | } |
| 4338 | } |
| 4339 | callback(); |
| 4340 | }); |
| 4341 | }, |
| 4342 | (err) => { |
| 4343 | if (err) return callback(/** @type {WebpackError} */ (err)); |
| 4344 | const hash = createHash(this._hashFunction); |
| 4345 | const tsHash = createHash(this._hashFunction); |
| 4346 | hash.update(entry.hash); |
| 4347 | if (entry.timestampHash) tsHash.update(entry.timestampHash); |
| 4348 | if (entry.safeTime) { |
| 4349 | safeTime = Math.max(safeTime, entry.safeTime); |
| 4350 | } |
| 4351 | hashes.sort(); |
| 4352 | for (const h of hashes) { |
| 4353 | hash.update(h); |
| 4354 | } |
| 4355 | tsHashes.sort(); |
| 4356 | for (const h of tsHashes) { |
| 4357 | tsHash.update(h); |
| 4358 | } |
| 4359 | callback( |
| 4360 | null, |
| 4361 | (entry.resolved = { |
| 4362 | safeTime, |
| 4363 | timestampHash: tsHash.digest(class="st">"hex"), |
| 4364 | hash: hash.digest(class="st">"hex") |
| 4365 | }) |
| 4366 | ); |
| 4367 | } |
no test coverage detected