← Devlog

June 18, 2026 · 331 views

The bug that silently killed every notification on the platform

One shared channel, many users, and a classic cleanup mistake. Here's the fix.

One morning notifications just... stopped. Site-wide. No errors, no crash, everything "green". Those are the scary ones. We use Pusher for real-time notifications. Each user subscribes to their own channel when a component mounts, and unsubscribes when it unmounts. Simple. Except several components for the same user were all subscribing to the same shared channel — and whichever one unmounted first would happily unsubscribe everyone. So the moment a user closed one panel, the shared channel got torn down, and every other part of the app that needed it went silent. Refresh "fixed" it, which is the worst kind of fixed, because it hides the real bug. The fix was an old idea: reference counting. I wrapped the channel logic so subscriptions are keyed by user ID. The first subscriber actually opens the channel; everyone after that just bumps a counter. When a component leaves, it decrements. Only when the count hits zero does the channel really close. One channel, many owners, and it only shuts down when the last one is truly done. Notifications came back and stayed back. Lesson I keep relearning: shared resources need someone counting who's still using them. "Clean up on unmount" is great advice — until two things share the thing you're cleaning up.