Skip to content

Commit

Permalink
fix: Fix crash due to race condition during interview (#21680)
Browse files Browse the repository at this point in the history
Fixes #21118
Mentioned in #21036 and #20688

Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
  • Loading branch information
srett and Koenkk authored Mar 5, 2024
1 parent e2fa66a commit 2da8095
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/zigbee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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});
});
Expand Down

0 comments on commit 2da8095

Please sign in to comment.