diff --git a/lib/tunnelbroker/peer-to-peer-context.js b/lib/tunnelbroker/peer-to-peer-context.js --- a/lib/tunnelbroker/peer-to-peer-context.js +++ b/lib/tunnelbroker/peer-to-peer-context.js @@ -194,7 +194,9 @@ ); await Promise.all(devicePromises); - return Object.keys(sentMessagesMap); + // Returning messageIDs of failed messages. + const sentMessages = new Set(Object.keys(sentMessagesMap)); + return messageIDs?.filter(id => !sentMessages.has(id)) ?? []; } const AUTOMATIC_RETRY_FREQUENCY = 30 * 1000;