Page MenuHomePhabricator

D13761.id45303.diff
No OneTemporary

D13761.id45303.diff

diff --git a/lib/tunnelbroker/peer-to-peer-message-handler.js b/lib/tunnelbroker/peer-to-peer-message-handler.js
--- a/lib/tunnelbroker/peer-to-peer-message-handler.js
+++ b/lib/tunnelbroker/peer-to-peer-message-handler.js
@@ -21,6 +21,7 @@
type PeerToPeerMessage,
} from '../types/tunnelbroker/peer-to-peer-message-types.js';
import { getConfig } from '../utils/config.js';
+import { getMessageForException } from '../utils/errors.js';
type Props = {
+socketSend: (message: string) => void,
@@ -78,7 +79,7 @@
try {
await peerToPeerMessageHandler(peerToPeerMessage, messageID);
} catch (e) {
- console.log(e.message);
+ console.log(getMessageForException(e));
} finally {
if (
localSocketSessionCounter === getSessionCounter() &&
@@ -119,7 +120,7 @@
} catch (e) {
console.log(
'error while parsing Tunnelbroker peer-to-peer message:',
- e.message,
+ getMessageForException(e),
);
// Client received incorrect message, confirm to remove from
// Tunnelbroker queue.
@@ -167,7 +168,10 @@
})),
);
} catch (e) {
- console.log('error while reading persisted inbound messages:', e.message);
+ console.log(
+ 'error while reading persisted inbound messages:',
+ getMessageForException(e),
+ );
}
}, [enqueue]);
diff --git a/lib/tunnelbroker/use-peer-to-peer-message-handler.js b/lib/tunnelbroker/use-peer-to-peer-message-handler.js
--- a/lib/tunnelbroker/use-peer-to-peer-message-handler.js
+++ b/lib/tunnelbroker/use-peer-to-peer-message-handler.js
@@ -206,7 +206,7 @@
await identityClient.getInboundKeysForUser(senderUserID);
deviceKeys = keys[senderDeviceID];
} catch (e) {
- console.log(e.message);
+ console.log(getMessageForException(e));
}
if (!deviceKeys) {
@@ -233,12 +233,13 @@
`session version: ${sessionVersion}`,
);
} catch (e) {
- if (e.message?.includes(olmSessionErrors.alreadyCreated)) {
+ const errorMessage = getMessageForException(e) ?? '';
+ if (errorMessage.includes(olmSessionErrors.alreadyCreated)) {
console.log(
'Received session request with lower session version from ' +
`${senderDeviceID}, session version: ${sessionVersion}`,
);
- } else if (e.message?.includes(olmSessionErrors.raceCondition)) {
+ } else if (errorMessage.includes(olmSessionErrors.raceCondition)) {
const currentDeviceID = await getContentSigningKey();
if (hasHigherDeviceID(currentDeviceID, senderDeviceID)) {
console.log(
@@ -263,7 +264,7 @@
} else {
console.log(
'Error creating inbound session with device ' +
- `${senderDeviceID}: ${e.message}, ` +
+ `${senderDeviceID}: ${errorMessage}, ` +
`session version: ${sessionVersion}`,
);
}
@@ -292,7 +293,8 @@
console.log('Failed processing Olm P2P message:', e);
}
} catch (e) {
- if (e.message?.includes(olmSessionErrors.invalidSessionVersion)) {
+ const errorMessage = getMessageForException(e) ?? '';
+ if (errorMessage.includes(olmSessionErrors.invalidSessionVersion)) {
console.log(
'Received message decrypted with different session from ' +
`${message.senderInfo.deviceID}.`,
@@ -301,10 +303,10 @@
}
console.log(
'Error decrypting message from device ' +
- `${message.senderInfo.deviceID}: ${e.message}`,
+ `${message.senderInfo.deviceID}: ${errorMessage}`,
);
- if (!e.message?.includes(OLM_ERROR_FLAG)) {
+ if (!errorMessage.includes(OLM_ERROR_FLAG)) {
throw e;
}
@@ -322,7 +324,9 @@
const oneTimeKeys = await olmAPI.getOneTimeKeys(message.numberOfKeys);
await identityClient.uploadOneTimeKeys(oneTimeKeys);
} catch (e) {
- console.log(`Error uploading one-time keys: ${e.message}`);
+ console.log(
+ `Error uploading one-time keys: ${getMessageForException(e) ?? ''}`,
+ );
}
} else if (message.type === peerToPeerMessageTypes.DEVICE_LIST_UPDATED) {
try {
diff --git a/lib/utils/peer-to-peer-communication-utils.js b/lib/utils/peer-to-peer-communication-utils.js
--- a/lib/utils/peer-to-peer-communication-utils.js
+++ b/lib/utils/peer-to-peer-communication-utils.js
@@ -1,6 +1,7 @@
// @flow
import { getConfig } from './config.js';
+import { getMessageForException } from './errors.js';
import { olmSessionErrors } from './olm-utils.js';
import { type AuthMetadata } from '../shared/identity-client-context.js';
import { type P2PMessageRecipient } from '../tunnelbroker/peer-to-peer-context.js';
@@ -88,7 +89,9 @@
};
return await sendMessageToPeer(encryptedMessage, authMetadata, sendMessage);
} catch (e) {
- if (e.message?.includes(olmSessionErrors.sessionDoesNotExist)) {
+ if (
+ getMessageForException(e)?.includes(olmSessionErrors.sessionDoesNotExist)
+ ) {
return 'missing_session';
}
console.log(`Error sending messages to peer ${message.deviceID}`, e);
@@ -178,7 +181,9 @@
return { status: 'success', recipient };
} catch (e) {
- if (e.message?.includes(olmSessionErrors.sessionDoesNotExist)) {
+ if (
+ getMessageForException(e)?.includes(olmSessionErrors.sessionDoesNotExist)
+ ) {
return { status: 'missing_session', recipient };
}
console.log(`Error sending messages to peer ${recipient.deviceID}`, e);

File Metadata

Mime Type
text/plain
Expires
Wed, Oct 23, 2:24 AM (21 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2344436
Default Alt Text
D13761.id45303.diff (5 KB)

Event Timeline