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)
Sun, Nov 10, 12:36 PM
Unknown Object (File)
Sun, Nov 10, 6:02 AM
Unknown Object (File)
Sun, Nov 10, 3:26 AM
Unknown Object (File)
Wed, Nov 6, 5:43 AM
Unknown Object (File)
Fri, Nov 1, 1:55 PM
Unknown Object (File)
Fri, Nov 1, 4:56 AM
Unknown Object (File)
Thu, Oct 31, 10:03 PM
Unknown Object (File)
Thu, Oct 31, 7:10 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
Branch
master
Lint
No Lint Coverage
Unit
No Test Coverage

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