Skip to content

Commit 9312d5d

Browse files
committed
docs(errors): document Windows EPERM alignment
1 parent 4600240 commit 9312d5d

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Security and Correctness
66

77
- Retry a contended file-lock acquisition when Windows denies access to a lock file whose directory entry is still being torn down, including when the native binding performs the exclusive create. Both the exclusive create and the holder's snapshot read reported that transient `EPERM` as a hard failure, so concurrent `acquireFileLock()` calls failed intermittently on Windows even though the very next attempt would have succeeded. Retries stay bounded, so a genuine permission denial still surfaces as `EPERM` rather than a lock timeout; thanks @Yigtwxx for the fix.
8+
- Report access-denied failures from native Windows operations as `EPERM` rather than `EACCES`, matching Node/libuv and the JavaScript fallback. Consumers that matched the previous native-only `EACCES` code should accept `EPERM` as well when supporting older package versions.
89

910
### Features
1011

‎docs/errors.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ The compiler will flag missing cases when you exhaust the union — keep your sw
142142

143143
## Distinguishing from `NodeJS.ErrnoException`
144144

145-
Some failures bubble up as native Node errors (e.g. `EACCES`, `EISDIR`, `EBUSY`) when they don't map cleanly to a library code. Inspect both:
145+
Some failures bubble up as native Node errors (e.g. `EACCES`, `EPERM`, `EISDIR`, `EBUSY`) when they don't map cleanly to a library code. Inspect both:
146146

147147
```ts
148148
import { FsSafeError } from "@openclaw/fs-safe";
@@ -154,7 +154,8 @@ try {
154154
handleFsSafe(err);
155155
return;
156156
}
157-
if ((err as NodeJS.ErrnoException).code === "EACCES") {
157+
const code = (err as NodeJS.ErrnoException).code;
158+
if (code === "EACCES" || code === "EPERM") {
158159
handleAccess();
159160
return;
160161
}
@@ -164,6 +165,8 @@ try {
164165

165166
A common pattern is to wrap your domain code in a single try/catch that maps both shapes to your application's typed error format.
166167

168+
On Windows, access-denied failures from native operations use `EPERM` to match Node/libuv and the JavaScript fallback. Older fs-safe versions could report `EACCES` for the same native condition, so consumers spanning versions should accept both codes.
169+
167170
## Specialty errors
168171

169172
A handful of helpers throw their own typed errors instead of `FsSafeError`:

0 commit comments

Comments
 (0)