argusqa-os 9.5.9 → 9.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -141,13 +141,18 @@ export async function analyzeVisualRegression(browser, url, opts = {}) {
141
141
  const baselinePath = path.join(baselineDir, `${slug}.png`);
142
142
 
143
143
  // ── 3. First run: save baseline ─────────────────────────────────────────────
144
- if (!fs.existsSync(baselinePath)) {
145
- try {
146
- fs.writeFileSync(baselinePath, currentBuf);
147
- } catch (err) {
144
+ // Use flag:'wx' for atomic create — throws EEXIST if baseline was written concurrently (TOCTOU-safe).
145
+ let baselineIsNew = false;
146
+ try {
147
+ fs.writeFileSync(baselinePath, currentBuf, { flag: 'wx' });
148
+ baselineIsNew = true;
149
+ } catch (err) {
150
+ if (err.code !== 'EEXIST') {
148
151
  logger.warn(`[ARGUS] visual-diff: could not write baseline ${baselinePath}: ${err.message}`);
149
152
  return findings;
150
153
  }
154
+ }
155
+ if (baselineIsNew) {
151
156
 
152
157
  findings.push({
153
158
  type: 'visual_baseline_created',