Skip to content

Commit

Permalink
[lib] Wait with processing inbound messages for Tunnelbroker connection
Browse files Browse the repository at this point in the history
Summary:
https://linear.app/comm/issue/ENG-9804/wait-with-processing-inbound-messages-for-tunnelbroker-connection

Depends on D13802

Test Plan:
1. Comment out code in removeInboundP2PMessages() function
2. Send some messages
3. Now getAllInboundP2PMessages() should always return something
4. Restart the app
5. Verify that:
- before the patch in the logs there are errors like "Error while sending confirmation: Tunnelbroker not connected [Error: Tunnelbroker not connected]"
- after the patch the errors should disappear

Reviewers: tomek, kamil

Reviewed By: kamil

Subscribers: ashoat

Differential Revision: https://phab.comm.dev/D13792
  • Loading branch information
graszka22 committed Oct 30, 2024
1 parent b51dd5e commit 9360b1f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/tunnelbroker/peer-to-peer-message-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type Props = {
function PeerToPeerMessageHandler(props: Props): React.Node {
const { socketSend, getSessionCounter, doesSocketExist } = props;

const { addListener, removeListener } = useTunnelbroker();
const { addListener, removeListener, socketState } = useTunnelbroker();
const peerToPeerMessageHandler = usePeerToPeerMessageHandler();
const handleOlmMessageToDevice = useHandleOlmMessageToDevice();
const persistedStateLoaded = usePersistedStateLoaded();
Expand Down Expand Up @@ -104,7 +104,10 @@ function PeerToPeerMessageHandler(props: Props): React.Node {
socketSend,
],
);
const { enqueue } = useActionsQueue(processItem, persistedStateLoaded);
const { enqueue } = useActionsQueue(
processItem,
persistedStateLoaded && !!socketState.isAuthorized,
);

const tunnelbrokerMessageListener = React.useCallback(
async (message: TunnelbrokerToDeviceMessage) => {
Expand Down

0 comments on commit 9360b1f

Please sign in to comment.