update 4.3 post mortum

Yazar: Auxim

Hello friends!

Yesterday, I released the 4.3 update bringing a lot of cool and interesting features to AltDentifier! Sadly, this update didn't go as smoothly as planned. In this post, I'll explain what happened exactly causing the update to take a long time to finally start up.

So to start, I woke up yesterday to release the update at 10 AM. I chose this time exactly, because the morning tends to be the calmest moment for AltDentifier, and it would be minimally disruptive. Again, that's what it would have been if things went smoothly, but they didn't. The first issue we had was something called a UnicodeDecodeError. This pretty much just means that it's assuming ASCII encoding instead of Unicode, which is easily fixed by explicitly stating that Python should use utf-8 encoding.
After fixing that issue, I let the bot start up, but later found out I had forgotten to update the discord library on the server side. While the bot would connect, no commands would actually get loaded. So, I updated the discord library on the server, restarted the bot and played some games while I waited for it to connect.

But it did not connect, even after 20 minutes, when it should have connected way earlier. I figured something was just acting weird, and gave it a restart. But it turned out, even restarting it didn't really help, and while I got the bot to start up once, I found out it would crash soon after. This also appeared to be the reason for the bot to take so long to connect, as it would crash while busy connecting.
Looking at my error handler, I quickly found out an error was reported where a message that was send or updated, would sometimes miss the User object from the Member object.
(A Member is a Discord User in the context of a specific server). I looked at the details of the error, and found out that the error occurred a few times. These errors would all point to a specific Member in a specific Discord Server. I removed AltDentifier from the server in question, as I had assumed it was in a glitched state, and restarted the bot again.

It was then that I discovered that that server wasn't the only culprit, multiple servers were having the same issue. I went over to the discord.py support server, where frankly, I didn't learn much. I spent a while modifying discord.py to see if I could in some way prevent or ignore the error, so that it wouldn't take down the whole process.
This didn't work out very well. I then decided that the best option would be to revert back to the old stable update, which I did, and the bot started without issue.
Still intrigued by what caused the update to go wrong, I decided that in order to test, I would merge the upstream discord.py code into the fork that I have, which has some small AltDentifier specific changes. I installed this new fork onto the server, and ran the 4.3 bot with the command handler and modules disabled, so that only a connection to Discord would be made, and nothing else would happen. To my surprise, the bot started up without any issues.
This made me wonder if the issues were caused by a certain module loading. I decided that I would restart the bot, but this time, enable the command handler without loading in the modules at startup. This way, I could run 4.2 stable while I booted 4.3. I then loaded all the modules using my developer loading command, killed the 4.2 bot, and killed the 4.2 site, starting up the 4.3 site. To my surprise, everything stayed completely stable, and after fixing some minor hiccups, finally, the update was live, and working as expected!

This day has proven a valuable lesson for me, and has made me decide to put even more emphasis on focussing completely on 5.0, that while not introducing any new features, is intended to be a complete cleanup of legacy code with massively improved stability and performance. I hope that even after these issues, you are still enjoying the 4.3 Update just as much as I enjoyed coding these new features. I'll write a friendly overview of this update soon, but for now, you can find the 4.3 Changelog on this very blog.

Thanks for coming to my TED talk!

Auxim