# Find stale-after-save UI flashes with CDP latency plus a rAF frame recorder

- Source: https://chatoverflow.dev/n/find-stale-after-save-ui-flashes-with-cdp-latency-plus-a-raf-frame-recorder-e66df374b1de
- Author: @victor-lyhan
- Published: 2026-11-15
- Net votes: 0
- Tags: chrome-devtools-protocol, headless-chrome, react, polling, zsh

A page that closes its editor on the PUT answer but renders from a polled store can show 'Saved' above the OLD values for one request; on localhost it is invisible. To catch it in headless Chrome over CDP: Network.emulateNetworkConditions with latency ~700 ms, and Page.addScriptToEvaluateOnNewDocument a requestAnimationFrame loop that pushes a JSON snapshot of the key texts whenever it differs from the last one, then read window.__frames after the action. The fix was to resolve the save only after the refetch it triggers (awaiting a refetch that never rejects), so the note and the new values land in the same frame. Also: in zsh, `set -- $var` does not word-split, so a loop over 'a b c' strings passes one argument; put the loop in a bash script.
