Dev.to WebDev 🛠 Dev 👁 0 📖 3 min read

Six production bugs in a WebRTC app, with the tests that keep them fixed

Chatter3 is a free 1-on-1 English conversation app (https://app.chatter3.com) — two learners, five minutes, one video call. This is the engineering log of six bugs that reached production, and every one of them is writte

Chatter3 is a free 1-on-1 English conversation app (https://app.chatter3.com) — two learners, five minutes, one video call. This is the engineering log of six bugs that reached production, and every one of them is written up with the code that runs and the test that keeps it fixed.

The notes live at https://chatter3-lab.github.io/ — plain HTML, one stylesheet, no CDN fonts and no analytics, because they have to be readable from a phone in mainland China.

The six notes

1. A frozen screen, and the sentence in the documentation that said why

The share button froze the HarmonyOS app. The cause was a window request answered with a controller that no component ever rendered — a documented way to block the render process. The fix was to render the requested window as a second component that is always in the tree, so its controller is attached when the request arrives.

2. The camera was granted, and the app still said it was denied

A protected resource has two permissions, not one: the system-level one and the one the page asks the host for. The shell never answered the second, so every request was refused. The fix is an onPermissionRequest handler that asks the system for ohos.permission.CAMERA / ohos.permission.MICROPHONE at the moment the page asks, and grants the page only if the system granted it.

3. A Durable Object that forgot one of the two people

The sockets stayed open, but a field holding them was lost when the object was evicted. One side sent everything; the other side received nothing. The fix is to never keep sockets in a field: the hibernation API is the only place they live.

4. A wider route ate a GDPR export request

"Export my data" answered User not found for every signed-in user, because a generic /api/user/<id> handler sat above it in the file. Route order is not a style question when the routes have different shapes.

5. "Your network blocked the call" when the other person never arrived

The failure reason was read out of the ICE statistics. But a connection that was never offered makes no candidates at all — and every statistic then looks like a blocked network. The fix is to check peer_not_joined before any ICE statistics, and to hide "Report connection issue" for that reason.

6. The timer that started before the call did

The countdown began at the moment of the match, so the waiting counted as conversation. Fixing it also uncovered a sign error that made two phones count down to different seconds: the skew is subtracted, not added.

The clock now belongs to the server. POST /api/matching/ready records user1_ready_at / user2_ready_at and sets call_started_at in one atomic statement; the client polls every two seconds and also signals over the socket; and the server's server_time_ms is the truth, with the client's skew computed against it.

The measurements

There is also a page with the first 133 sessions measured on the live server — how long a call takes to connect, and how often the other person never comes — with the query that produced every number and the limits of the sample attached: https://chatter3-lab.github.io/data/

Eight sessions ended because the partner never arrived. One was a genuine network failure. The product was telling its users to fix their networks nine times out of ten.

Why these are public

These are the kinds of bug that every video call app has and none of them write down. The notes are here because the fixes are more useful to the next person than the app is, and because a page with real code on it is a page a search engine can quote.

The app itself is free: https://app.chatter3.com

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.