From 4fb4b498a18da69210773ac61e1d61fee8084d12 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Sun, 18 Jan 2026 22:13:33 +0000 Subject: [PATCH] Add timeout error --- README.md | 1 - frontend/test-client/src/cli.ts | 5 +++-- frontend/test-client/src/utils/with-timeout.ts | 11 ++++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7ffb78ca..6ca7975b 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,5 @@ And to clean up the logs & database files, run `task clean` - [Sync server](./sync-server/README.md) -a create that has been processed by the server but got lost on the way back will create a 2nd doc if it gets edited remove force merge everywhere diff --git a/frontend/test-client/src/cli.ts b/frontend/test-client/src/cli.ts index 1f90743e..45421660 100644 --- a/frontend/test-client/src/cli.ts +++ b/frontend/test-client/src/cli.ts @@ -4,6 +4,7 @@ import { MockAgent } from "./agent/mock-agent"; import { sleep } from "./utils/sleep"; import { v4 as uuidv4 } from "uuid"; import { randomCasing } from "./utils/random-casing"; +import { TimeoutError } from "./utils/with-timeout"; const TEST_ITERATIONS = 5; const MAX_INITIAL_DOCS = 0; @@ -95,7 +96,7 @@ async function runTest({ logger.info(`Finishing up ${client.name}`); await client.finish(); } catch (err) { - if (!slowFileEvents) { + if (err instanceof TimeoutError || !slowFileEvents) { throw err; } } @@ -107,7 +108,7 @@ async function runTest({ logger.info(`Destroying ${client.name}`); await client.destroy(); } catch (err) { - if (!slowFileEvents) { + if (err instanceof TimeoutError || !slowFileEvents) { throw err; } } diff --git a/frontend/test-client/src/utils/with-timeout.ts b/frontend/test-client/src/utils/with-timeout.ts index 71c9568b..6e0e4e04 100644 --- a/frontend/test-client/src/utils/with-timeout.ts +++ b/frontend/test-client/src/utils/with-timeout.ts @@ -1,3 +1,5 @@ +import { __debug_locks } from "sync-client"; + export async function withTimeout( promise: Promise, timeoutMs: number, @@ -8,9 +10,16 @@ export async function withTimeout( new Promise((_, reject) => setTimeout(() => { reject( - new Error(`${operationName} timed out after ${timeoutMs}ms`) + new TimeoutError(`${operationName} timed out after ${timeoutMs}ms ${__debug_locks.map(lock => lock.getDebugString()).join(", ")}`) ); }, timeoutMs) ) ]); } + +export class TimeoutError extends Error { + constructor(message: string) { + super(message); + this.name = "TimeoutError"; + } +} \ No newline at end of file