Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): Windows saves no longer fail while a scanner holds the file #16574

Closedyaacovcorcos(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/16574/headopened View on GitHub

Showing 2 changed files with 143 additions and 1 deletion.

x
0 of 2 viewed, 2 left
120 additions and 0 deletionsapps/server/src/atomicWrite.test.tsModified
View file
@@ -1,11 +1,15 @@
import * as NodeServices from "@effect/platform-node/NodeServices";
+import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
import { assert, it } from "@effect/vitest";
+import * as Deferred from "effect/Deferred";
import * as Effect from "effect/Effect";
import * as Exit from "effect/Exit";
+import * as Fiber from "effect/Fiber";
import * as FileSystem from "effect/FileSystem";
import * as Layer from "effect/Layer";
import * as Path from "effect/Path";
import * as PlatformError from "effect/PlatformError";
+import * as TestClock from "effect/testing/TestClock";
​
import { writeFileStringAtomically } from "./atomicWrite.ts";
​
@@ -101,6 +105,113 @@
assert.strictEqual(yield* fs.readFileString(filePath), "fresh");
}),
+​
+ it.effect("retries a Windows replacement while another process holds the target", () =>
+ Effect.gen(function* () {
+ const fs = yield* FileSystem.FileSystem;
+ const path = yield* Path.Path;
+ const root = yield* fs.makeTempDirectoryScoped({ prefix: "t3-atomic-write-" });
+ const filePath = path.join(root, "settings.json");
+ yield* fs.writeFileString(filePath, "before");
+ const firstAttempt = yield* Deferred.make<void>();
+ let attempts = 0;