From aa7df4b5c2421f853f4e5d7c058d1e0f7f4babdc Mon Sep 17 00:00:00 2001 From: Alexander Harding Date: Wed, 12 Nov 2025 20:09:55 -0600 Subject: [PATCH] fix: unable to catch ensureClient error --- src/ThreadiverseClient.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ThreadiverseClient.ts b/src/ThreadiverseClient.ts index cb7eec6..a4e4a47 100644 --- a/src/ThreadiverseClient.ts +++ b/src/ThreadiverseClient.ts @@ -25,7 +25,7 @@ export default class ThreadiverseClient implements BaseClient { !this.discoveredSoftware ) throw new Error( - "Client not initialized. Wait for getSoftware() or any other async method to resolve first", + "Client not initialized. Wait for getSoftware() or any other async method to resolve first" ); return { @@ -433,13 +433,14 @@ export default class ThreadiverseClient implements BaseClient { if (!this.discoveredSoftware) { if (!discoveryCache.has(this.hostname)) { const resolver = resolveSoftware(this.hostname, this.options); - discoveryCache.set(this.hostname, resolver); - resolver.catch((e) => { + try { + await resolver; + } catch (e) { discoveryCache.delete(this.hostname); throw e; - }); + } } this.discoveredSoftware = await discoveryCache.get(this.hostname)!; } @@ -449,7 +450,7 @@ export default class ThreadiverseClient implements BaseClient { if (!Client) { throw new UnsupportedSoftwareError( - `${this.discoveredSoftware.name} v${this.discoveredSoftware.version} is not supported`, + `${this.discoveredSoftware.name} v${this.discoveredSoftware.version} is not supported` ); }