Skip to content

Commit 1a06b7f

Browse files
fix(server): tolerate unsupported Windows directory flushes
1 parent a4ee5d2 commit 1a06b7f

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

‎apps/server/src/auth/ServerSecretStore.ts‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,15 @@ export const make = Effect.gen(function* () {
247247
);
248248
// Publish complete bytes without replacing a concurrent creator's secret.
249249
yield* fileSystem.link(temporaryPath, secretPath);
250-
const directory = yield* fileSystem.open(serverConfig.secretsDir, { flag: "r" });
251-
yield* directory.sync.pipe(
252-
Effect.catch((cause) =>
253-
platform === "win32" &&
254-
Predicate.hasProperty(cause.reason.cause, "code") &&
255-
cause.reason.cause.code === "EPERM"
256-
? Effect.void
257-
: Effect.fail(cause),
250+
// Windows may reject either opening or syncing a directory handle.
251+
yield* fileSystem.open(serverConfig.secretsDir, { flag: "r" }).pipe(
252+
Effect.flatMap((directory) => directory.sync),
253+
Effect.catchIf(
254+
(cause) =>
255+
platform === "win32" &&
256+
Predicate.hasProperty(cause.reason.cause, "code") &&
257+
cause.reason.cause.code === "EPERM",
258+
() => Effect.void,
258259
),
259260
);
260261
}),

0 commit comments

Comments
 (0)