Closed th0mas closed 4 years ago
Fixed in c428991
@th0mas fix looks good. 👍 Is there any way to write a test for this? ✍️ So we know it works in the future and nobody accidentally breaks it? 💭
This fix just polls the socket until we can reach the server, then re-runs the startup procedure and handshake process.
I'm not sure how i'd go about testing this, as we'd have to simulate a Hub server failing then starting again.
Yeah, it's convoluted to test. But sometimes it's worth it because it's a bit of brain-gym! 🧠 We want our systems to be as fault tolerant / reliable as possible so forcing yourself to think of how to test things is a really good exercise. And it's always an opportunity to learn new things. For example: I learned that I could have a "mini phoenix" app inside a test: https://github.com/dwyl/ping/blob/465204a975d93d89f62a45d075903f5a5189aeac/test/ping_test.exs#L17-L35
If you prefer to focus on your next task, that's fine.
Just get into the habit of thinking "How do I know this is working reliably". (_i.e. always following the scientific method_)
Having good complete tests is the only way to never get calls at 2am on boxing day because something "broke". 🎁 💩
Note: I'm pretty confident that the fix you have applied in this case works (for now...). I'm just paranoid about writing any code without tests. 🤷♂️ I once quit a job over exactly this. 👎 (that was the original impetus for: https://github.com/dwyl/learn-tdd ...) The lead dev didn't want to write tests but still expected the team to be responsible for the quality of the code. ROFL! 🤦 (I wish I was joking. I'm not. There are still way too many people who think it's "OK" to never write tests ...)
If you always write tests, you will be able to expect
high quality from everyone you work with. 🥇
Which means you will be able to work at highly interesting places like https://www.tesla.com/careers/search#/?department=4
When loosing connection to the hub, devices running the firmware fail to reconnect to the Hub server on the correct channel.
They reconnect to the socket, but do not join the communication channel.