From 2da80954d69c753bcfbef30c2579584d7a0f8779 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 5 Mar 2024 21:28:35 +0100 Subject: [PATCH] fix: Fix crash due to race condition during interview (#21680) Fixes #21118 Mentioned in #21036 and #20688 Co-authored-by: Koen Kanters --- lib/zigbee.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/zigbee.ts b/lib/zigbee.ts index e69dd6619..467d7d1d2 100644 --- a/lib/zigbee.ts +++ b/lib/zigbee.ts @@ -88,16 +88,16 @@ export default class Zigbee { }); this.herdsman.on('deviceInterview', async (data: ZHEvents.DeviceInterviewPayload) => { const device = this.resolveDevice(data.device.ieeeAddr); - await device.resolveDefinition(); /* istanbul ignore if */ if (!device) return; // Prevent potential race + await device.resolveDefinition(); const d = {device, status: data.status}; this.logDeviceInterview(d); this.eventBus.emitDeviceInterview(d); }); this.herdsman.on('deviceJoined', async (data: ZHEvents.DeviceJoinedPayload) => { const device = this.resolveDevice(data.device.ieeeAddr); - await device.resolveDefinition(); /* istanbul ignore if */ if (!device) return; // Prevent potential race + await device.resolveDefinition(); logger.info(`Device '${device.name}' joined`); this.eventBus.emitDeviceJoined({device}); });