Rethinking state machines when nothing agrees on loaded
Modeling UI state across three runtimes that each have their own idea of truth.
This is a sample post. Replace it with your actual writing.
The problem
When you have a frontend that spans multiple runtimes — a service worker, a main thread, and maybe an iframe or web worker — they each maintain their own version of reality.
const states = {
idle: 'idle',
loading: 'loading',
loaded: 'loaded',
error: 'error',
};
The question isn’t what your states are. It’s who gets to decide when a transition happens.
A practical approach
Start by accepting that consensus is expensive. Instead of trying to synchronize state across runtimes, give each runtime its own local state machine and reconcile at known checkpoints.
The best distributed systems don’t try to eliminate disagreement. They make disagreement cheap to resolve.
This changed how I think about frontend architecture entirely.