From 8be3be4994d82607ebfef65fe4d189f59ec3abf2 Mon Sep 17 00:00:00 2001 From: automated-signal <37887102+automated-signal@users.noreply.github.com> Date: Fri, 8 May 2026 15:28:36 -0500 Subject: [PATCH] ourProfileKey.doGet: Wait no more than 30 seconds for blocking promises Co-authored-by: Scott Nonnenberg --- ts/services/ourProfileKey.std.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ts/services/ourProfileKey.std.ts b/ts/services/ourProfileKey.std.ts index 8983a76f8a..35edddc83e 100644 --- a/ts/services/ourProfileKey.std.ts +++ b/ts/services/ourProfileKey.std.ts @@ -3,6 +3,8 @@ import { assertDev, strictAssert } from '../util/assert.std.ts'; import { createLogger } from '../logging/log.std.ts'; +import { sleep } from '../util/sleep.std.ts'; +import { SECOND } from '../util/durations/constants.std.ts'; import type { StorageInterface } from '../types/Storage.d.ts'; @@ -59,11 +61,15 @@ export class OurProfileKeyService { } async #doGet(): Promise> { - log.info( - `Our profile key service: waiting for ${this.#promisesBlockingGet.length} promises before fetching` - ); - - await Promise.allSettled(this.#promisesBlockingGet); + if (this.#promisesBlockingGet.length > 0) { + log.info( + `Our profile key service: waiting for ${this.#promisesBlockingGet.length} promises before fetching` + ); + await Promise.race([ + Promise.allSettled(this.#promisesBlockingGet), + sleep(30 * SECOND), + ]); + } this.#promisesBlockingGet = []; delete this.getPromise;