From 8cb45ba9de41243a89381a0d89f99919d20737d5 Mon Sep 17 00:00:00 2001 From: 4gray Date: Sat, 1 Aug 2026 22:19:49 +0200 Subject: [PATCH] fix(stalker): move pendingAuth cleanup out of the promise initializer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TS2454 under the Angular compiler: the finally block referenced authPromise inside its own initializer, so every Electron/web production build failed even though jest and lint accepted it. Await the promise at the call site and retire the map entry there instead — same only-clear-our-own-entry semantics. Co-Authored-By: Claude Opus 5 --- .../src/lib/stalker-session.service.ts | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/libs/portal/stalker/data-access/src/lib/stalker-session.service.ts b/libs/portal/stalker/data-access/src/lib/stalker-session.service.ts index daeadfde4..f28ee91c1 100644 --- a/libs/portal/stalker/data-access/src/lib/stalker-session.service.ts +++ b/libs/portal/stalker/data-access/src/lib/stalker-session.service.ts @@ -552,27 +552,29 @@ export class StalkerSessionService { let accountInfo: StalkerProfileResponse['js']['account_info']; const authPromise = (async () => { - try { - const result = await this.authenticate( - portalUrl, - macAddress, - identity - ); - accountInfo = result.accountInfo; - this.setCachedToken(playlist._id, result.token); - return { - token: result.token, - serialNumber: identity.serialNumber, - }; - } finally { - if (this.pendingAuth.get(playlist._id) === authPromise) { - this.pendingAuth.delete(playlist._id); - } - } + const result = await this.authenticate( + portalUrl, + macAddress, + identity + ); + accountInfo = result.accountInfo; + this.setCachedToken(playlist._id, result.token); + return { + token: result.token, + serialNumber: identity.serialNumber, + }; })(); this.pendingAuth.set(playlist._id, authPromise); - await authPromise; + try { + await authPromise; + } finally { + // Only retire our own entry: a caller that started a later + // authentication owns the map slot from then on. + if (this.pendingAuth.get(playlist._id) === authPromise) { + this.pendingAuth.delete(playlist._id); + } + } return accountInfo; }