A Late Device Refresh Overwrites a Newer Status
Level 2 · node · Concurrency · Stale asynchronous response overwrites newer device state
Scenario
A fictional indoor device dashboard may refresh the same device repeatedly before earlier requests finish. A later request can finish first. The current service writes responses in completion order, so an older request that finishes late can replace the newer status. Review the asynchronous refresh flow through the repository and controller.
Requirements
For each device, only the most recently started refresh may update the stored status. A stale response must not overwrite a newer result. Keep refreshes for different devices independent, preserve single-refresh behavior and stored state on fetch failures, and retain the existing API without external packages.
Acceptance criteria
- An older response arriving late cannot overwrite the latest device status.
- A single device refresh is stored and readable as before.
- Refreshes for different devices remain independent.
- The latest refresh remains visible regardless of completion order.
- A failed fetch does not erase the previously stored valid status.
- The refresh API returns the current device status after updating.