From f36463e292f4487daef522ec9b19c2dacceb6adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Wed, 11 Nov 2026 08:17:42 +0000 Subject: [PATCH] fix(core): fall back to a direct write when link() is denied with EACCES (#7474) * fix(core): fall back to a direct write when link() is denied with EACCES On Android app data (Termux, SELinux enforcing), link(2) fails with EACCES in a folder the temp file was just written to. createFileAtomically() and the studio history owner lock treated that as fatal, so `hyperframes init` left a half-scaffolded project and every render logged a recordRenderSuccess failure. Both now take their existing exclusive direct-write path, as they already do for EPERM. Fixes #7473 * fix(share): treat EACCES as no hard links in the project share lock Same Termux/SELinux link() denial as core and the studio history lock: the share lock's link-then-exclusive-create fallback now covers it too. Folds the Android note into the existing comment so no file's comment share rises. --- packages/core/src/atomicFile.test.ts | 2 +- packages/core/src/atomicFile.ts | 4 ++-- packages/studio-server/src/history/ownerLock.test.ts | 2 +- packages/studio-server/src/history/ownerLock.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/core/src/atomicFile.test.ts b/packages/core/src/atomicFile.test.ts index d5cfb891e0..83a55b2386 100644 --- a/packages/core/src/atomicFile.test.ts +++ b/packages/core/src/atomicFile.test.ts @@ -242,7 +242,7 @@ describe("createFileAtomically", () => { }; } - it.each(["EPERM", "ENOTSUP", "EOPNOTSUPP", "EXDEV", "EISDIR"])( + it.each(["EPERM", "ENOTSUP", "EOPNOTSUPP", "EXDEV", "EISDIR", "EACCES"])( "writes directly on a volume without hard links (%s)", (code) => { const dir = tempDir(); diff --git a/packages/core/src/atomicFile.ts b/packages/core/src/atomicFile.ts index a79103e544..3416d000f8 100644 --- a/packages/core/src/atomicFile.ts +++ b/packages/core/src/atomicFile.ts @@ -7,9 +7,9 @@ import { renameWithRetry } from "./renameWithRetry.js"; type SiblingFileSystem = Pick; type DirectFileSystem = SiblingFileSystem & Pick; -// Codes a volume without hard links (FAT, exFAT, some network shares) answers link() with. +// Codes a volume without hard links (FAT, exFAT, some network shares, Android app data) answers link() with. // EISDIR: libuv maps Windows ERROR_INVALID_FUNCTION (FAT/exFAT refusing a link) to it; nodejs/node#65817. -const NO_HARD_LINKS = new Set(["EPERM", "ENOTSUP", "EOPNOTSUPP", "EXDEV", "EISDIR"]); +const NO_HARD_LINKS = new Set(["EPERM", "ENOTSUP", "EOPNOTSUPP", "EXDEV", "EISDIR", "EACCES"]); const MAX_LINK_HOPS = 40; const TEMP_NAME_TRIES = 3; const TEMP_SUFFIX = /\.hf[0-9a-f]{6}\.tmp$/; diff --git a/packages/studio-server/src/history/ownerLock.test.ts b/packages/studio-server/src/history/ownerLock.test.ts index 6dcc7caff6..1183cd6eed 100644 --- a/packages/studio-server/src/history/ownerLock.test.ts +++ b/packages/studio-server/src/history/ownerLock.test.ts @@ -95,7 +95,7 @@ function withoutHardLinks(code = "ENOTSUP"): void { } describe("takeHistoryOwnership on a drive without hard links", () => { - it.each(["ENOTSUP", "EOPNOTSUPP", "ENOSYS", "EPERM"])( + it.each(["ENOTSUP", "EOPNOTSUPP", "ENOSYS", "EPERM", "EACCES"])( "takes the lock when linking fails with %s", async (code) => { withoutHardLinks(code); diff --git a/packages/studio-server/src/history/ownerLock.ts b/packages/studio-server/src/history/ownerLock.ts index 235c6e8546..e58336eac0 100644 --- a/packages/studio-server/src/history/ownerLock.ts +++ b/packages/studio-server/src/history/ownerLock.ts @@ -16,7 +16,7 @@ export class HistoryBusyError extends Error { } const WINDOWS_BUSY = new Set(["EPERM", "EBUSY", "EACCES"]); -const NO_HARD_LINKS = new Set(["ENOTSUP", "EOPNOTSUPP", "ENOSYS", "EPERM"]); +const NO_HARD_LINKS = new Set(["ENOTSUP", "EOPNOTSUPP", "ENOSYS", "EPERM", "EACCES"]); const TAKING_MS = 2_000; const BOOT_SLACK_MS = 60_000;