Skip to content

Commit 8600654

Browse files
fix timeout (#144)
1 parent 71aebab commit 8600654

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/ConfigurationClientManager.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,16 @@ export class ConfigurationClientManager {
140140

141141
async #discoverFallbackClients(host: string) {
142142
let result;
143+
let timeout;
143144
try {
144145
result = await Promise.race([
145-
new Promise((_, reject) => setTimeout(() => reject(new Error("SRV record query timed out.")), SRV_QUERY_TIMEOUT)),
146+
new Promise((_, reject) => timeout = setTimeout(() => reject(new Error("SRV record query timed out.")), SRV_QUERY_TIMEOUT)),
146147
this.#querySrvTargetHost(host)
147148
]);
148149
} catch (error) {
149150
throw new Error(`Failed to build fallback clients, ${error.message}`);
151+
} finally {
152+
clearTimeout(timeout);
150153
}
151154

152155
const srvTargetHosts = shuffleList(result) as string[];

0 commit comments

Comments
 (0)