diff --git a/lib/authentication/auth_web.js b/lib/authentication/auth_web.js index 4055422b4..17ea8da98 100644 --- a/lib/authentication/auth_web.js +++ b/lib/authentication/auth_web.js @@ -177,12 +177,15 @@ function AuthWeb(connectionConfig, httpClient, webbrowser) { } const withBrowserActionTimeout = (millis, promise) => { + let timeoutId; + const timeout = new Promise((resolve, reject) => - setTimeout( + timeoutId = setTimeout( () => reject(`Browser action timed out after ${browserActionTimeout} ms.`), millis)); + return Promise.race([ - promise, + promise.finally(() => clearTimeout(timeoutId)), timeout ]); };