libp2p / observer-toolkit

🐣 [WIP] toolkit for building libp2p introspection widgets + a few useful out-of-the-box widgets
https://libp2p.io
MIT License
2 stars 2 forks source link

Sort timeline X-axis to handle out-of-sequence states #52

Closed AlanSl closed 4 years ago

AlanSl commented 4 years ago

I found a few more even rarer instances of the "messed up timeline with websockets data" bug after the latest fixes, and figured out that they were caused by states being sent out of sequence.

Rather than fixing whatever in the mock data server is causing states to be sent out of sequence, based on the principle of "correctly render whatever data is thrown at us" I've added x-axis sorting to the timeline and related hooks so that out-of-sequence data is still rendered correctly. Since we don't have control over the introspection server it's good to have resilience. I've checked the performance and this extra sort adds less than 1ms to the time taken to handle incoming states even when out of sequence.