Urgent.News

What's breaking now, across thousands of outlets.

Tech

Four bugs my test suite couldn't catch

216 passing tests. A feature that was completely broken. Here is the gap between those two facts, and what I changed afterwards. The feature I am building an encrypted messenger. Messages are end to end encrypted, and the server relaying them cannot read anything. That part worked. What I added was offline delivery. If you message someone whose app is closed, the server should hold the message,…

The source material describes several bugs discovered in a test suite for an encrypted messenger application. The first bug is a race condition caused by asynchronous loading of decryption keys from browser storage, which resulted in decrypted messages being dropped. The solution was to restore the state before connecting to the server.

The second bug involved acknowledging the wrong event, leading to the deletion of data that had not been fully processed. The fix was to confirm message handling only after it had been completed successfully.

The third bug was a cleanup path that never ran, causing messages to accumulate on the server side when both users were online. A solution was to store messages only when no recipients were available to receive them.

The fourth bug occurred when removing a chat, which deleted messages but left encryption keys behind. If the same person was re-added, the app would attempt to resume a conversation that had been discarded by the other side. The fix was to delete everything derived from a deleted thing, preventing orphaned state from causing issues.

The author concludes that the key to finding these bugs was running the test suite against the deployed build, simulating real-world usage. This approach uncovered four critical bugs, two of which resulted in user data loss. The author emphasizes that tests are essential for ensuring individual components function correctly, but they are inadequate for testing the entire system.

The author's approach involved testing against the actual deployed software, which led to the discovery of these bugs and improved the overall reliability of the messenger application.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

bro.js v3.0.0 – What’s new

Tired of flaky state leaking between tests or worrying about insecure defaults? bro.js just hit v3.0.0 and brings a bunch of practical upgrades that let you focus on code, not on runtime quirks.

Automating Deployment with Github Actions

Deploying to a Server You Can't Reach: Building a CI/CD Pipeline with AWS SSM and OIDC From pushing code manually to building, testing, containerizing, and deploying every change automatically.

Kernel prepatch 7.3-rc4

Linus Torvalds has released the 7.3-rc4 kernel prepatch. It is, unsurprisingly at this point, large: " We all know the drill by now: 'it's big, yadda yadda' ".

More from Sunday 20 September →