Skip to content

Commit

Permalink
fix: the initial write does not need to be atomic
Browse files Browse the repository at this point in the history
It is only written if the file does not exist due to the 'wx' flag.
  • Loading branch information
midgleyc committed May 2, 2023
1 parent 2e71bac commit 4d53d2e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/remix-node/sessions/fileStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function createFileSessionStorage<Data = SessionData, FlashData = Data>({
try {
let file = getFile(dir, id);
await fsp.mkdir(path.dirname(file), { recursive: true });
await writeFile(file, content, { encoding: "utf-8" });
await fsp.writeFile(file, content, { encoding: "utf-8", flag: "wx" });
return id;
} catch (error: any) {
if (error.code !== "EEXIST") throw error;
Expand Down

0 comments on commit 4d53d2e

Please sign in to comment.