Skip to content

Commit

Permalink
Fix historian null reference
Browse files Browse the repository at this point in the history
If an MQTT packet was received without custom properties, an exception was thrown. The added optional chaining prevents this error.
  • Loading branch information
djnewbould authored and amrc-benmorrow committed Nov 27, 2024
1 parent f025fe7 commit 40d7916
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion historian-uns/src/mqttclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export default class MQTTClient {

async on_message(topicString: string, payload: Buffer, packet: mqtt.IPublishPacket) {
const messageString = payload.toString();
if (!packet.properties.userProperties) {
if (!packet.properties?.userProperties) {
logger.error(`⁉ Can't find custom properties for topic ${topicString}! Not writing to Influx.`);
return
}
Expand Down

0 comments on commit 40d7916

Please sign in to comment.