Skip to content

Commit 052936e

Browse files
committed
Clear timeout if the brower action promise resolves before timeout
1 parent 00e3b95 commit 052936e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/authentication/auth_web.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,15 @@ function AuthWeb(connectionConfig, httpClient, webbrowser) {
177177
}
178178

179179
const withBrowserActionTimeout = (millis, promise) => {
180+
let timeoutId;
181+
180182
const timeout = new Promise((resolve, reject) =>
181-
setTimeout(
183+
timeoutId = setTimeout(
182184
() => reject(`Browser action timed out after ${browserActionTimeout} ms.`),
183185
millis));
186+
184187
return Promise.race([
185-
promise,
188+
promise.finally(() => clearTimeout(timeoutId)),
186189
timeout
187190
]);
188191
};

0 commit comments

Comments
 (0)