Good evening witches and wizards!
I would like to tell you the story of the spookiest bug #Ditto has ever seen. And I'm happy to announce that on this All Hallows Eve, nostr:nprofile1qydhwumn8ghj7emvv4shxmmwv96x7u3wv3jhvtmjv4kxz7gqyr6aee5wfxntmwh60cg6gtemheducg0qw9f3xawcsmfmh2frn87tknnsjdp and I worked together to make the spectral ghost visible and vanquish it! 👻
The story begins with nostr:nprofile1qydhwumn8ghj7emvv4shxmmwv96x7u3wv3jhvtmjv4kxz7gqyqeuw3p87wetw0278re7djv3cy322hfqgper2mm3mfy6pcsfld55qyg3pnp (Verita84), who faced this problem so bad he actually left Nostr and went back to the Fediverse.
The problem being: that no matter how hard he tried, he could not log in. He tried other browsers, deleted all data, turned his computer off and back on again. But although it worked perfectly 100% of the time on his other device, it worked 0% of the time on this device.
As the months went on, we received a few complaints here and there from people saying they could NEVER log in to Ditto on a particular device. But our team could never reproduce this problem. So it eluded us. But we would occasionally still hear rare complaints of it.
Well today nostr:nprofile1qydhwumn8ghj7emvv4shxmmwv96x7u3wv3jhvtmjv4kxz7gqyr6aee5wfxntmwh60cg6gtemheducg0qw9f3xawcsmfmh2frn87tknnsjdp was experiencing the exact same issue. So I added more logs, and he sent screenshots and videos, and we collaborated for several hours. I carefully combed through every line of code in the whole flow, and absolutely nothing was wrong!
Finally I thought to find the NIP-46 event in the Ditto logs, and it occurred to me to check its timestamp. Because there is a 10 second limit on these events, after which the relay would silently reject them.
Strangely, the event's created_at timestamp was actually 12 seconds _before_ the Ditto log timestamp... Hmm...
I assumed he must have a very slow computer, or network connection. But he assured me it was very fast. I raised the limit from 10 seconds to 1 minute anyway. And you know what? IT FUCKING WORKED.
(I also added special treatment for ephemeral events in Ditto, so they would throw an error if they didn't get streamed out, instead of just absorbing it.)
But I told him, since his network was so slow, he would have to wait 12 seconds to log in... But to my surprise, he told me he didn't wait 12 seconds at all. It was instantaneous.
And then it dawned on me. THE CLOCK ON HIS COMPUTER WAS WRONG.
HE TESTED HIS CLOCK, AND IT WAS 12 SECONDS BEHIND!!!!!!!
Date.now() in JavaScript was getting the time from his OS, and his OS had a wrong clock! So the event was getting rejected as being too old.
Holy shit! I couldn't believe it! I still can't believe it! Months of anxiety and terror finally resolved by a fucking clock.
So my friends, remember that this Halloween, the scariest thing is not goblins and ghosts. it's time. Time ages us and destroys us. But it is a reality we have to live with. Let us embrace death! To accept the afterlife is to be free.
Thank you very much my spooky friends and have a Happy Halloween! 👻 🎃 💀
https://gitlab.com/soapbox-pub/ditto/-/merge_requests/576
nostr:nevent1qvzqqqqqqypzpawuu68ynf4ahta8uydy9uamuk7vy8s8z5cnwhvgd5am4y3enl9mqydhwumn8ghj7emvv4shxmmwv96x7u3wv3jhvtmjv4kxz7gqyrd9rqq9panr7e5nrfk64fwah2k5jamxnm4s9e3z3lm728rnnpdkqkhfae6