From 4a17f034e24f1bcbed3067166e184e933cf17746 Mon Sep 17 00:00:00 2001 From: Sergey Galuza Date: Sun, 23 Aug 2026 08:33:06 +0200 Subject: [PATCH] docs(shared-manager): note why the CAS mismatch raises EEXIST The code is this file's marker for "a race was detected" - the same one the reappeared-path and concurrent-replacement guards raise - not a report that a no-replace link() or open('wx') hit an existing path. Say so at the throw, so debugging by err.code does not send anyone looking for a no-replace failure that never happened. Built [OnSteroids](https://onsteroids.ai) --- src/management/shared-manager/diverged-file-adopter.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/management/shared-manager/diverged-file-adopter.ts b/src/management/shared-manager/diverged-file-adopter.ts index 2e42f7e2..fb075b5b 100644 --- a/src/management/shared-manager/diverged-file-adopter.ts +++ b/src/management/shared-manager/diverged-file-adopter.ts @@ -264,6 +264,9 @@ function publishCanonicalContent( const currentStats = getLstatSync(writePath); const current = currentStats?.isFile() ? canonicalIdentityOf(currentStats) : null; if (!canonicalIdentityMatches(expected, current)) { + // EEXIST is this file's marker for "a race was detected", the same code + // the reappeared-path and concurrent-replacement guards raise. It does + // not mean a no-replace link() or open('wx') hit an existing path. throw Object.assign(new TypeError(`Canonical file changed during adoption: ${writePath}`), { code: 'EEXIST', });