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 @@ -30,6 +30,7 @@ } from '../types/tunnelbroker/peer-to-peer-message-types.js'; import { getConfig } from '../utils/config.js'; import { getMessageForException } from '../utils/errors.js'; +import { olmSessionErrors } from '../utils/olm-utils.js'; import { useDispatch, useSelector } from '../utils/redux-utils.js'; type PeerToPeerContextType = { @@ -132,6 +133,10 @@ }; await sendMessageToPeer(encryptedMessage); } catch (e) { + if (!e.message?.includes(olmSessionErrors.sessionDoesNotExists)) { + console.log(`Error sending messages to peer ${peerDeviceID}`, e); + break; + } try { await peerOlmSessionsCreator(message.userID, peerDeviceID); const result = await olmAPI.encryptAndPersist( @@ -287,7 +292,14 @@ deviceID: recipient.deviceID, payload: JSON.stringify(encryptedMessage), }); - } catch { + } catch (e) { + if (!e.message?.includes(olmSessionErrors.sessionDoesNotExists)) { + console.log( + `Error sending messages to peer ${recipient.deviceID}`, + e, + ); + return; + } try { await peerOlmSessionsCreator(recipient.userID, recipient.deviceID); const encryptedData = await olmAPI.encrypt(