@mintlify/previewing 4.0.1684 → 4.0.1686
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.
|
@@ -5,8 +5,8 @@ import fse from 'fs-extra';
|
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { formatDiagnostic, loadPackageBuilder } from '../../packages/builder.js';
|
|
7
7
|
import { formatProblem, PackageIslandCollector, } from '../../packages/collect.js';
|
|
8
|
-
import { errnoCode } from '../../packages/errno.js';
|
|
9
8
|
import { DocsJsonError, InvalidPackagesError, readPackagesSetup, } from '../../packages/setup.js';
|
|
9
|
+
import { retryFileRename } from '../../retry-file-rename.js';
|
|
10
10
|
import { setPackageImportOptions } from './state.js';
|
|
11
11
|
export const PACKAGE_BUILD_PROPS_FILE = 'package-build.json';
|
|
12
12
|
const PENDING_BUILD_ID = 'pending';
|
|
@@ -34,21 +34,6 @@ const mtimeOf = (file) => {
|
|
|
34
34
|
return undefined;
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
const RENAME_RETRY_CODES = new Set(['EPERM', 'EBUSY', 'EACCES']);
|
|
38
|
-
async function replaceFile(from, to, attempts = 20) {
|
|
39
|
-
for (let attempt = 1;; attempt++) {
|
|
40
|
-
try {
|
|
41
|
-
await fse.rename(from, to);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
const code = errnoCode(error);
|
|
46
|
-
if (attempt >= attempts || !code || !RENAME_RETRY_CODES.has(code))
|
|
47
|
-
throw error;
|
|
48
|
-
await new Promise((resolve) => setTimeout(resolve, 10 * attempt));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
37
|
export class PackagesDev {
|
|
53
38
|
constructor(options) {
|
|
54
39
|
this.options = options;
|
|
@@ -177,7 +162,7 @@ export class PackagesDev {
|
|
|
177
162
|
css: this.adopted?.manifest.css ?? [],
|
|
178
163
|
};
|
|
179
164
|
await fse.outputFile(tmp, JSON.stringify(props));
|
|
180
|
-
await
|
|
165
|
+
await retryFileRename(() => fse.rename(tmp, target));
|
|
181
166
|
}
|
|
182
167
|
close() {
|
|
183
168
|
this.closed = true;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function retryFileRename(rename: () => Promise<void>): Promise<void>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { errnoCode } from './packages/errno.js';
|
|
2
|
+
const RENAME_RETRY_CODES = new Set(['EPERM', 'EBUSY', 'EACCES']);
|
|
3
|
+
const MAX_RENAME_ATTEMPTS = 20;
|
|
4
|
+
export async function retryFileRename(rename) {
|
|
5
|
+
for (let attempt = 1;; attempt++) {
|
|
6
|
+
try {
|
|
7
|
+
await rename();
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
const code = errnoCode(error);
|
|
12
|
+
if (attempt >= MAX_RENAME_ATTEMPTS || !code || !RENAME_RETRY_CODES.has(code))
|
|
13
|
+
throw error;
|
|
14
|
+
await new Promise((resolve) => setTimeout(resolve, 10 * attempt));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|