for automatic review

This commit is contained in:
vorotamoroz
2026-06-17 05:51:01 +01:00
parent 497fd04081
commit 2d5cdccf7d
24 changed files with 123 additions and 85 deletions
+3 -2
View File
@@ -2,14 +2,15 @@ import type { LiveSyncBaseCore } from "@/LiveSyncBaseCore";
import { P2P_DEFAULT_SETTINGS } from "@lib/common/types";
import type { ServiceContext } from "@lib/services/base/ServiceBase";
import { LiveSyncTrysteroReplicator } from "@lib/replication/trystero/LiveSyncTrysteroReplicator";
import { addP2PEventHandlers } from "@lib/replication/trystero/addP2PEventHandlers";
import { compatGlobal } from "@lib/common/coreEnvFunctions.ts";
type CLIP2PPeer = {
peerId: string;
name: string;
};
function delay(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
return new Promise((resolve) => compatGlobal.setTimeout(resolve, ms));
}
export function parseTimeoutSeconds(value: string, commandName: string): number {
+4 -3
View File
@@ -18,6 +18,7 @@ import { promptForPassphrase, readStdinAsUtf8, toArrayBuffer, toDatabaseRelative
import { collectPeers, openP2PHost, parseTimeoutSeconds, syncWithPeer } from "./p2p";
import { performFullScan } from "@lib/serviceFeatures/offlineScanner";
import { UnresolvedErrorManager } from "@lib/services/base/UnresolvedErrorManager";
import { compatGlobal } from "@lib/common/coreEnvFunctions.ts";
function redactConnectionString(uri: string): string {
return uri.replace(/\/\/([^@/]+)@/u, "//***@");
@@ -150,11 +151,11 @@ export async function runCommand(options: CLIOptions, context: CLICommandContext
);
}
}
pollTimer = setTimeout(poll, currentIntervalMs);
pollTimer = compatGlobal.setTimeout(poll, currentIntervalMs);
};
let pollTimer: ReturnType<typeof setTimeout> = setTimeout(poll, currentIntervalMs);
let pollTimer = compatGlobal.setTimeout(poll, currentIntervalMs);
core.services.appLifecycle.onUnload.addHandler(async () => {
clearTimeout(pollTimer);
compatGlobal.clearTimeout(pollTimer);
return true;
});
} else {
+2 -1
View File
@@ -3,6 +3,7 @@ import { applyRemoteSyncSettings, initSettingsFile } from "./helpers/settings.ts
import { assertFilesEqual, runCliOrFail } from "./helpers/cli.ts";
import { startCouchdb, stopCouchdb } from "./helpers/docker.ts";
import { createDeterministicDataset, type DatasetEntry } from "./helpers/dataset.ts";
import { compatGlobal } from "@lib/common/coreEnvFunctions.ts";
type BenchmarkConfig = {
couchdbBackendUri: string;
@@ -137,7 +138,7 @@ function startCouchdbProxy(options: { backendUri: string; proxyUri: string; requ
},
},
async (request) => {
await new Promise((resolve) => setTimeout(resolve, halfDelayMs));
await new Promise((resolve) => compatGlobal.setTimeout(resolve, halfDelayMs));
const targetUrl = new URL(request.url);
targetUrl.protocol = backend.protocol;
@@ -1,5 +1,6 @@
import { CLI_DIR, TEE_ENABLED, formatTeeCommand, createLineTeeWriter } from "./cli.ts";
import { join } from "@std/path";
import { compatGlobal } from "@lib/common/coreEnvFunctions.ts";
const CLI_DIST = join(CLI_DIR, "dist", "index.cjs");
const VERBOSE_ENABLED = Deno.env.get("LIVESYNC_CLI_VERBOSE") === "1";
@@ -77,7 +78,9 @@ export class BackgroundCliProcess {
if (this.combined.includes(needle)) return;
const status = await Promise.race([
this.child.status.then((s) => ({ type: "status" as const, status: s })),
new Promise<{ type: "tick" }>((resolve) => setTimeout(() => resolve({ type: "tick" }), 100)),
new Promise<{ type: "tick" }>((resolve) =>
compatGlobal.setTimeout(() => resolve({ type: "tick" }), 100)
),
]);
if (status.type === "status") {
throw new Error(
+2 -1
View File
@@ -1,4 +1,5 @@
import { join } from "@std/path";
import { compatGlobal } from "@lib/common/coreEnvFunctions.ts";
// ---------------------------------------------------------------------------
// Path resolution
@@ -25,7 +26,7 @@ const VERBOSE_ENABLED = Deno.env.get("LIVESYNC_CLI_VERBOSE") === "1";
const DEBUG_ENABLED = Deno.env.get("LIVESYNC_CLI_DEBUG") === "1";
function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
return new Promise((resolve) => compatGlobal.setTimeout(resolve, ms));
}
function concatChunks(chunks: Uint8Array[]): Uint8Array {
+3 -1
View File
@@ -1,3 +1,5 @@
import { compatGlobal } from "@lib/common/coreEnvFunctions.ts";
/**
* Docker service management for tests.
*
@@ -256,7 +258,7 @@ function untrackContainer(container: string): void {
}
function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
return new Promise((resolve) => compatGlobal.setTimeout(resolve, ms));
}
async function waitForCouchdbStable(hostname: string, user: string, password: string): Promise<void> {
+5 -3
View File
@@ -1,3 +1,5 @@
import { compatGlobal } from "@lib/common/coreEnvFunctions.ts";
type WaitForPortOptions = {
timeoutMs?: number;
intervalMs?: number;
@@ -5,7 +7,7 @@ type WaitForPortOptions = {
};
function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
return new Promise((resolve) => compatGlobal.setTimeout(resolve, ms));
}
async function connectWithTimeout(hostname: string, port: number, timeoutMs: number): Promise<void> {
@@ -13,13 +15,13 @@ async function connectWithTimeout(hostname: string, port: number, timeoutMs: num
try {
const connPromise = Deno.connect({ hostname, port });
const timeoutPromise = new Promise<never>((_, reject) => {
timer = setTimeout(() => reject(new Error(`connect timeout after ${timeoutMs}ms`)), timeoutMs);
timer = compatGlobal.setTimeout(() => reject(new Error(`connect timeout after ${timeoutMs}ms`)), timeoutMs);
});
const conn = await Promise.race([connPromise, timeoutPromise]);
conn.close();
} finally {
if (timer !== undefined) {
clearTimeout(timer);
compatGlobal.clearTimeout(timer);
}
}
}
+2 -1
View File
@@ -1,6 +1,7 @@
import { runCli } from "./cli.ts";
import { isLocalP2pRelay, startP2pRelay, stopP2pRelay, startCoturn, stopCoturn } from "./docker.ts";
import { waitForPort } from "./net.ts";
import { compatGlobal } from "@lib/common/coreEnvFunctions.ts";
export type PeerEntry = {
id: string;
@@ -8,7 +9,7 @@ export type PeerEntry = {
};
function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
return new Promise((resolve) => compatGlobal.setTimeout(resolve, ms));
}
function parseRelayEndpoint(relay: string): { hostname: string; port: number } {
@@ -28,6 +28,7 @@ import { TempDir } from "./helpers/temp.ts";
import { runCliOrFail, jsonFieldIsNa } from "./helpers/cli.ts";
import { applyCouchdbSettings, initSettingsFile } from "./helpers/settings.ts";
import { startCouchdb, stopCouchdb } from "./helpers/docker.ts";
import { compatGlobal } from "@lib/common/coreEnvFunctions.ts";
// ---------------------------------------------------------------------------
// Load configuration
@@ -109,7 +110,7 @@ async function runSuite(
config: { uri: string; user: string; password: string },
dbname: string
): Promise<void> {
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
const sleep = (ms: number) => new Promise((resolve) => compatGlobal.setTimeout(resolve, ms));
const runWithRetry = async <T>(label: string, fn: () => Promise<T>, retries = SYNC_RETRY): Promise<T> => {
let lastErr: unknown;
for (let i = 0; i <= retries; i++) {