Use the queue instead of processing operations in a loop.
https://linear.app/comm/issue/ENG-9470/mitigate-risks-of-effects-running-on-outdated-data
Differential D13623
[lib] Use queue when processing inbound messages from the DB tomek on Oct 7 2024, 5:17 AM. Authored by Tags None Referenced Files
Subscribers
Details Use the queue instead of processing operations in a loop. https://linear.app/comm/issue/ENG-9470/mitigate-risks-of-effects-running-on-outdated-data Disabled inbound messages processing by commenting out handleOlmMessageToDevice in usePeerToPeerMessageHandler. 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
Event TimelineComment Actions 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...
|