Symptom

Android logcat storm at app launch: with 3 saved servers, each server node was re-processed 100+ times within ~150 ms — endless cycles of loading stored host - updating nodes and executingExecuting nodecollected node ... PROCESSINGconnectNodealready connected, plus LocalSwarmHost init: loading 0 local nodes repeating dozens of times and the Client node re-collected with a monotonically increasing timestamp on every cycle. The loop never converged; it just burned CPU on ~20 dispatcher threads.

Root cause

A self-sustaining dispatch loop across three pieces:

  1. DefaultNodeObserver dispatches the node’s processor on every StateFlow emission.
  2. ClientClientProcessor.process() (the Client node’s processor) re-ran its entire startup body on every dispatch — fileOperations.load(), update() + execute() for every stored server host (each execute() stamps PROCESSING with a fresh timestamp → more emissions → more ClientServerProcessor.connectNode dispatches), beacon start, and LocalSwarmHost.init().
  3. ClientNodeManager.reset() — called unconditionally at the end of process() — stamped state = NONE, timestamp = now() even when the client node was already NONE. The fresh timestamp defeats StateFlow conflation, so the flow re-emitted, the observer re-dispatched process(), and the cycle repeated forever.

A secondary race: the observer’s collector dispatched node.value (re-read at dispatch time) instead of the collectedNode it was woken for, so under concurrent updates the same latest value could be dispatched repeatedly while the actual transition was skipped.

Fix

Prevention