From 77e0bb4caffb42d863e38ca2a8497183efd498f4 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Fri, 5 Dec 2025 22:33:33 +0000 Subject: [PATCH] Await all --- frontend/sync-client/src/index.ts | 4 +++- frontend/test-client/src/agent/mock-agent.ts | 5 ++--- frontend/test-client/src/cli.ts | 9 ++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/frontend/sync-client/src/index.ts b/frontend/sync-client/src/index.ts index f09d339c..a7292ec2 100644 --- a/frontend/sync-client/src/index.ts +++ b/frontend/sync-client/src/index.ts @@ -1,3 +1,4 @@ +import { awaitAll } from "./utils/await-all"; import { logToConsole } from "./utils/debugging/log-to-console"; import { slowFetchFactory } from "./utils/debugging/slow-fetch-factory"; import { slowWebSocketFactory } from "./utils/debugging/slow-web-socket-factory"; @@ -41,5 +42,6 @@ export const debugging = { export const utils = { getRandomColor, positionToLineAndColumn, - lineAndColumnToPosition + lineAndColumnToPosition, + awaitAll }; diff --git a/frontend/test-client/src/agent/mock-agent.ts b/frontend/test-client/src/agent/mock-agent.ts index c1ff527b..ac525685 100644 --- a/frontend/test-client/src/agent/mock-agent.ts +++ b/frontend/test-client/src/agent/mock-agent.ts @@ -2,7 +2,7 @@ import { choose } from "../utils/choose"; import { v4 as uuidv4 } from "uuid"; import { assert } from "../utils/assert"; import type { RelativePath, SyncSettings } from "sync-client"; -import { debugging, Logger, LogLevel } from "sync-client"; +import { debugging, Logger, LogLevel, utils } from "sync-client"; import { MockClient } from "./mock-client"; import { sleep } from "../utils/sleep"; import type { LogLine } from "sync-client"; @@ -140,8 +140,7 @@ export class MockAgent extends MockClient { await withTimeout( (async (): Promise => { await this.client.setSetting("isSyncEnabled", true); - // eslint-disable-next-line no-restricted-properties - await Promise.all(this.pendingActions); + await utils.awaitAll(this.pendingActions); await this.client.waitUntilFinished(); })(), TIMEOUT_MS, diff --git a/frontend/test-client/src/cli.ts b/frontend/test-client/src/cli.ts index 60eb3386..08dbf472 100644 --- a/frontend/test-client/src/cli.ts +++ b/frontend/test-client/src/cli.ts @@ -1,4 +1,5 @@ import type { SyncSettings } from "sync-client"; +import { utils } from "sync-client"; import { MockAgent } from "./agent/mock-agent"; import { sleep } from "./utils/sleep"; import { v4 as uuidv4 } from "uuid"; @@ -56,14 +57,12 @@ async function runTest({ } try { - // eslint-disable-next-line no-restricted-properties - await Promise.all(clients.map(async (client) => client.init())); + await utils.awaitAll(clients.map(async (client) => client.init())); for (let i = 0; i < iterations; i++) { console.info(`Iteration ${i + 1}/${iterations}`); - // eslint-disable-next-line no-restricted-properties - await Promise.all(clients.map(async (client) => client.act())); - await sleep(100); + await utils.awaitAll(clients.map(async (client) => client.act())); + await sleep(Math.random() * 200); } console.info("Stopping agents");