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 Nov 23, 2022
1 parent a80b73f commit 02d29f8
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 @@ -52,7 +52,7 @@ export function createFileSessionStorage({
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 02d29f8

Please sign in to comment.