Page MenuHomePhabricator

[lib] Use queue when processing inbound messages from the DB
ClosedPublic

Authored by tomek on Oct 7 2024, 5:17 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Dec 18, 8:38 AM
Unknown Object (File)
Wed, Dec 18, 8:38 AM
Unknown Object (File)
Wed, Dec 18, 8:37 AM
Unknown Object (File)
Thu, Dec 5, 8:22 PM
Unknown Object (File)
Fri, Nov 29, 7:16 AM
Unknown Object (File)
Nov 20 2024, 9:06 AM
Unknown Object (File)
Nov 20 2024, 9:06 AM
Unknown Object (File)
Nov 18 2024, 1:40 AM
Subscribers

Details

Summary
Test Plan

Disabled inbound messages processing by commenting out handleOlmMessageToDevice in usePeerToPeerMessageHandler.
On one device, created a thread, changed its name, and then its description. These operations weren't processed on another device. Refreshed the app so that the operations are read from the DB and processed. Made sure that the result is correct.

Checked what was the behavior before this diff. Surprisingly, it was the same. Using the queue here sounds more correct and feels safer, but the previous approach also works correctly.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

tomek requested review of this revision.Oct 7 2024, 5:35 AM
kamil requested changes to this revision.Oct 9 2024, 1:51 AM

I feel like we duplicating logic here now, having two queues, the best solution here will be to use only useActionsQueue and get rid off

const [messagesQueue, setMessagesQueue] = React.useState<
  $ReadOnlyArray<{
    +peerToPeerMessage: PeerToPeerMessage,
    +messageID: string,
    +localSocketSessionCounter: number,
  }>,
>([]);

The only change will be to update tunnelbrokerMessageListener, instead of calling setMessagesQueue should call enqueue. Looks easy, but I guess there is some complexity so curious about @tomek's perspective, and requesting changes to discuss this.

BTW the initial pseudocode for useActionQueue suggested in https://phab.comm.dev/D13563#380765 was inspired by this very logic based on const [messagesQueue, setMessagesQueue] = React.useState...

This revision now requires changes to proceed.Oct 9 2024, 1:51 AM

Merge operation queues

kamil added inline comments.
lib/tunnelbroker/peer-to-peer-message-handler.js
173–199 ↗(On Diff #45094)

This could cause issues, we should start queueing messages from TB from the very start - the fix should be easy because we don't care about messages order anymore

This revision is now accepted and ready to land.Oct 14 2024, 3:21 AM

Delete unnecessary dependencies