FLOW LGX · PROBLEM SOLVED · SEPTEMBER 2026

Problem solved: live notifications that recover after the network drops

Real-time features look great in a demo on office Wi-Fi. In a warehouse with patchy signal, or on a laptop that goes to sleep, connections drop all the time. A notification system that silently stops working is worse than none at all.

About this project

Month by month, how a logistics platform for a Toronto client went from a simple brief to a live, multi-company SaaS product.

In short

When the internet drops, notifications reconnect on their own and reload from the server, so counts are never left wrong.

The problem

A live connection can fail quietly. The page still looks fine, but nothing new arrives, and the user assumes there is nothing to see. Messages sent while the user was offline are simply missed. And if every reconnect attempt fires instantly, a dropped connection can flood the server with retries.

The approach

The notification system lives in one React hook with a few rules:

  • The socket connects over WebSocket only and sends the user’s access token, so the server knows exactly who is listening.
  • Reconnection is automatic, with a delay that starts at one second and grows to five, and a maximum number of attempts so a dead connection does not retry forever.
  • Every connect, error, disconnect and reconnect is handled in one hook, and the attempt counter resets after a successful connection.
  • Messages are treated as a signal, not as the data. When a notification arrives, the app tells TanStack Query that the notifications list and unread count are out of date, and they are fetched fresh from the server.

Why “refresh, don’t trust” matters

Because the screen always reloads from the server after a signal, a missed message does not leave the user with a wrong count. The next signal — or simply reconnecting — brings the list back to the truth. The server stays the single source of truth, and the live connection only says when to look.

Lesson learned

Use real-time messages to say “something changed”, then fetch the truth. A missed message should cost a second of delay, never a wrong number.