Investigate deadlock (#178)

This commit is contained in:
Andras Schmelczer 2025-12-05 22:34:14 +00:00 committed by GitHub
parent 564d4a6c37
commit 7a13cb57ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 85 additions and 17 deletions

View file

@ -0,0 +1,16 @@
export async function withTimeout<T>(
promise: Promise<T>,
timeoutMs: number,
operationName: string
): Promise<T> {
return Promise.race([
promise,
new Promise<T>((_, reject) =>
setTimeout(() => {
reject(
new Error(`${operationName} timed out after ${timeoutMs}ms`)
);
}, timeoutMs)
)
]);
}