From 755393a7305a430b88c225fa5d199d91020e8320 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Fri, 20 Dec 2024 23:27:51 +0100 Subject: [PATCH] Fixes MDNS exception (#1547) --- packages/protocol/src/mdns/MdnsScanner.ts | 41 ++++++++++++----------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/packages/protocol/src/mdns/MdnsScanner.ts b/packages/protocol/src/mdns/MdnsScanner.ts index e47480545..bac0bd401 100644 --- a/packages/protocol/src/mdns/MdnsScanner.ts +++ b/packages/protocol/src/mdns/MdnsScanner.ts @@ -782,25 +782,28 @@ export class MdnsScanner implements Scanner { } } - return { - operational: combinedAnswers.operational - ? Object.fromEntries( - Object.entries(combinedAnswers.operational).map(([recordType, records]) => [ - recordType, - Array.from(records.values()), - ]), - ) - : undefined, - commissionable: combinedAnswers.commissionable - ? Object.fromEntries( - Object.entries(combinedAnswers.commissionable).map(([recordType, records]) => [ - recordType, - Array.from(records.values()), - ]), - ) - : undefined, - addresses: combinedAnswers.addresses, - }; + const result: StructuredDnsAnswers = {}; + if (combinedAnswers.operational) { + result.operational = Object.fromEntries( + Object.entries(combinedAnswers.operational).map(([recordType, records]) => [ + recordType, + Array.from(records.values()), + ]), + ); + } + if (combinedAnswers.commissionable) { + result.commissionable = Object.fromEntries( + Object.entries(combinedAnswers.commissionable).map(([recordType, records]) => [ + recordType, + Array.from(records.values()), + ]), + ); + } + if (combinedAnswers.addresses) { + result.addresses = combinedAnswers.addresses; + } + + return result; } /**