Guard async init against stale enable/disable cycles with epoch counter

This commit is contained in:
Jalil Arfaoui 2026-02-27 00:38:15 +01:00
parent d0ad901aab
commit 956f4b5916

View file

@ -120,12 +120,15 @@ export default class WifiSignalPlusExtension extends Extension {
private nearbyUpdatePending = false; private nearbyUpdatePending = false;
private currentConnectedBssid: string | undefined; private currentConnectedBssid: string | undefined;
private isMenuOpen = false; private isMenuOpen = false;
private enableEpoch = 0;
enable(): void { enable(): void {
const epoch = ++this.enableEpoch;
this.wifiService = new WifiInfoService(); this.wifiService = new WifiInfoService();
this.wifiService this.wifiService
.init() .init()
.then(() => { .then(() => {
if (epoch !== this.enableEpoch) return;
if (!this.wifiService) return; if (!this.wifiService) return;
this.wifiService.requestScan(); this.wifiService.requestScan();
this.wifiService.watchDeviceSignals(() => { this.wifiService.watchDeviceSignals(() => {