Page MenuHomePhabricator

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

Authored by tomek on Mon, Oct 7, 5:17 AM.
Tags
None
Referenced Files
F3001809: D13623.diff
Fri, Oct 18, 5:25 AM
F3001409: D13623.id45094.diff
Fri, Oct 18, 4:28 AM
F2997168: D13623.id.diff
Thu, Oct 17, 6:09 PM
F2996649: D13623.id45095.diff
Thu, Oct 17, 2:05 PM
Unknown Object (File)
Thu, Oct 17, 12:28 AM
Unknown Object (File)
Wed, Oct 16, 11:49 AM
Unknown Object (File)
Tue, Oct 15, 8:54 AM
Unknown Object (File)
Mon, Oct 14, 10:31 PM
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
No Lint Coverage
Unit
No Test Coverage

Event Timeline

tomek requested review of this revision.Mon, Oct 7, 5:35 AM
kamil requested changes to this revision.Wed, Oct 9, 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.Wed, Oct 9, 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.Mon, Oct 14, 3:21 AM

Delete unnecessary dependencies