@antelopejs/dms 0.21.4-next.1009.gbc3beff → 0.21.4-next.1010.g20da340
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/e2e/run-state.mjs +40 -2
- package/package.json +2 -2
package/e2e/run-state.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
rmSync,
|
|
9
9
|
writeFileSync,
|
|
10
10
|
} from "node:fs";
|
|
11
|
-
import { tmpdir } from "node:os";
|
|
11
|
+
import { platform, tmpdir } from "node:os";
|
|
12
12
|
import { join, resolve } from "node:path";
|
|
13
13
|
import { describeFailure } from "./failure.mjs";
|
|
14
14
|
import { assertSameNamespaces } from "./identity.mjs";
|
|
@@ -26,6 +26,9 @@ import {
|
|
|
26
26
|
} from "./json.mjs";
|
|
27
27
|
|
|
28
28
|
const RUN_FILE = "run.json";
|
|
29
|
+
const REPLACE_RETRY_MS = 2_000;
|
|
30
|
+
const REPLACE_POLL_MS = 5;
|
|
31
|
+
const REPLACE_PAUSE = new Int32Array(new SharedArrayBuffer(4));
|
|
29
32
|
const ID_BYTES = 3;
|
|
30
33
|
const TIMESTAMP_LENGTH = 15;
|
|
31
34
|
|
|
@@ -275,7 +278,42 @@ export function saveRun(state) {
|
|
|
275
278
|
writeFileSync(`${file}.next`, `${JSON.stringify(state, null, 2)}\n`, {
|
|
276
279
|
mode: 0o600,
|
|
277
280
|
});
|
|
278
|
-
|
|
281
|
+
replaceFile(`${file}.next`, file);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Renames `from` over `to`. Windows refuses with EPERM to replace a file
|
|
286
|
+
* another process holds open, as a service loading the run does for a
|
|
287
|
+
* moment, so there the rename is tried again until that read is done.
|
|
288
|
+
*
|
|
289
|
+
* @param {string} from The new file
|
|
290
|
+
* @param {string} to The file it replaces
|
|
291
|
+
* @throws When the rename fails for another reason, or Windows still refuses it after {@link REPLACE_RETRY_MS}
|
|
292
|
+
*/
|
|
293
|
+
function replaceFile(from, to) {
|
|
294
|
+
const deadline = Date.now() + REPLACE_RETRY_MS;
|
|
295
|
+
for (;;) {
|
|
296
|
+
try {
|
|
297
|
+
renameSync(from, to);
|
|
298
|
+
return;
|
|
299
|
+
} catch (error) {
|
|
300
|
+
if (!isHeldOpen(error) || Date.now() >= deadline) throw error;
|
|
301
|
+
Atomics.wait(REPLACE_PAUSE, 0, 0, REPLACE_POLL_MS);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* @param {unknown} error
|
|
308
|
+
* @returns {boolean}
|
|
309
|
+
*/
|
|
310
|
+
function isHeldOpen(error) {
|
|
311
|
+
return (
|
|
312
|
+
platform() === "win32" &&
|
|
313
|
+
error instanceof Error &&
|
|
314
|
+
"code" in error &&
|
|
315
|
+
error.code === "EPERM"
|
|
316
|
+
);
|
|
279
317
|
}
|
|
280
318
|
|
|
281
319
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/dms",
|
|
3
|
-
"version": "0.21.4-next.
|
|
3
|
+
"version": "0.21.4-next.1010.g20da340",
|
|
4
4
|
"description": "AntelopeJS DMS. Plug in your PostgreSQL, MySQL, MariaDB, MongoDB or RethinkDB database and your coding agent builds a back office and analytics dashboard as typed TypeScript. Real-time updates on the data the DMS manages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
@@ -213,7 +213,7 @@
|
|
|
213
213
|
"optional": true
|
|
214
214
|
}
|
|
215
215
|
},
|
|
216
|
-
"gitHead": "
|
|
216
|
+
"gitHead": "20da3403735474fa48edf015298c76495922d1c4",
|
|
217
217
|
"scripts": {
|
|
218
218
|
"build": "pnpm --filter @antelopejs/interface-dms --filter @antelopejs/interface-dms-builder build && rimraf dist && antelopejs-tsc && tsc-alias && tsc -p e2e/tsconfig.types.json",
|
|
219
219
|
"dev": "ajs project run --inspect -w -p playground",
|