Genie React

You clicked 7 days and got 90 days of data: catching request races in React

A slow 90-day response landed after the 7-day one and overwrote the chart. Genie's timeline and Redux log show which response won, and verify waits for the late response before it grades the fix.

You clicked Last 90 days, then Last 7 days, and the chart drew 90 days of data under a pressed 7-day button. The 90-day request started first and finished last, and the loadReports thunk stored whichever response came back, so the stale one won.

Genie shows both facts. The timeline request lane shows the order the requests finished in. The Redux log shows which thunk's result the store applied. Genie's verify check then grades the fix, and it waits for the slow request before it decides.

Everything below ran on 2026-11-19 with Genie 1.1.0, and the missing-collector refusal with Genie 1.1.1, against apps/realworld-legacy, a React 18 app in this repo with webpack and hand-written Redux thunks. The raw evidence has every command and its full output.

Make the race happen every time

A race that depends on network luck is hard to debug. The app ships a fault tool, so make the 90-day throughput request 1200 ms slower:

npx genie-react call app_backend_faults '{"rules":[{"method":"GET","path":"/api/reports/throughput","query":{"range":"90d"},"latencyMs":1200}]}' --session upd-a
rules[1]:
  - {method:GET,path:/api/reports/throughput,query:{range:90d},latencyMs:1200,status:null,times:null,hits:0}

The fault fixes the order, so every run shows the same race.

The screen disagrees with the button

Record a timeline with plain query values, click both buttons, and read the screen:

npx genie-react call timeline_start '{"name":"range switch","queryValues":"plain"}' --session upd-a --json
agent-browser --session upd-a find role button click --name 'Last 90 days' && agent-browser --session upd-a find role button click --name 'Last 7 days'
agent-browser --session upd-a wait 2000
npx genie-react call react_quiesce '{"idleMs":500,"timeoutMs":10000}' --fail-on-result-error --session upd-a --fields outcome,elapsedMs
npx genie-react call timeline_stop '{"id":"timeline-30f30778-63cc-40a1-8ff1-fc36a7ca66d6"}' --session upd-a --fields stopReason,eventCount,truncated,queryValues
agent-browser --session upd-a eval "JSON.stringify({pressed: document.querySelector('[aria-label=\"Date range\"] [aria-pressed=true]').textContent, chartRange: document.querySelector('.bar-chart').dataset.range, bars: document.querySelectorAll('.bar-chart__bar').length})"
"{\"pressed\":\"Last 7 days\",\"chartRange\":\"90d\",\"bars\":13}"

The pressed button says 7 days. The chart has 13 weekly bars from the 90-day report. A 7-day chart has 7 daily bars.

The request lane shows the race

npx genie-react call timeline_read '{"id":"timeline-30f30778-63cc-40a1-8ff1-fc36a7ca66d6","domains":["request"]}' --session upd-a --fields atMs,details

Trimmed to the two throughput requests:

  - {atMs:133.3,details:{url:http://127.0.0.1:5231/api/reports/throughput,query:"?project=CORE&range=7d",startMs:70.8,endMs:133,durationMs:62.2,bodyReadMs:133.3,finishedAfterNewer:false,bodyReadLast:false}}
  - {atMs:1312,details:{url:http://127.0.0.1:5231/api/reports/throughput,query:"?project=CORE&range=90d",startMs:37.9,endMs:1301.4,durationMs:1263.5,bodyReadMs:1302.2,finishedAfterNewer:true,bodyReadLast:true}}

The 90-day request started at 37.9 ms and the 7-day one at 70.8 ms. The 7-day response arrived at 133 ms. The 90-day response arrived at 1301.4 ms, so Genie marks it finishedAfterNewer: true. bodyReadLast: true says the app read its body last. The timeline docs call that pair the classic response race.

The network lane cannot see what the app did with each body. For that, ask the store.

The Redux log shows which response won

Genie's Redux collector records each action with the thunk that dispatched it as parentActionId. Read the reports/ actions after the clicks (sequence 146 was the last action before them):

npx genie-react call redux_actions '{"afterSequence":146,"typePrefix":"reports/","view":"full"}' --session upd-a --json | jq -c '{matched, records: [.records[] | {sequence, type, parentActionId, range: .payload.range, throughputRange: .payload.throughput.range, total: .payload.throughput.total}]}'
{"matched":4,"records":[{"sequence":148,"type":"reports/REQUESTED","parentActionId":"redux-store:1/action:147","range":"90d","throughputRange":null,"total":null},{"sequence":166,"type":"reports/REQUESTED","parentActionId":"redux-store:1/action:165","range":"7d","throughputRange":null,"total":null},{"sequence":183,"type":"reports/RECEIVED","parentActionId":"redux-store:1/action:165","range":null,"throughputRange":"7d","total":9},{"sequence":200,"type":"reports/RECEIVED","parentActionId":"redux-store:1/action:147","range":null,"throughputRange":"90d","total":33}]}

Thunk 147 asked for 90 days. Thunk 165 asked for 7 days. The 7-day data arrived first (sequence 183), then thunk 147 dispatched its 90-day data on top (sequence 200). matched: 4 counts the matches after afterSequence. Genie 1.0.2 counted every retained match and printed 8 here. The store's range still says 7 days:

npx genie-react call redux_state '{"path":["reports","range"]}' --session upd-a
path: [reports,range]
found: true
value: 7d

And the component on screen holds the 90-day report:

npx genie-react call react_inspect_component '{"id":11268819779757}' --session upd-a --select /props
result:
  report:
    project: CORE
    range: 90d
    total: 33
    buckets: {__genie_dehydrated__:true,kind:array,preview:"Array(13)",path:[report,buckets],size:13}

The thunk stores whichever response lands last

src/features/reports/state/actions.ts
export function loadReports(projectKey: string, range: ReportRange): ReportsThunk {
  return async (dispatch) => {
    dispatch({ type: REPORTS_REQUESTED, projectKey, range })
    // …
      const [throughput, cycleTime, workload] = await Promise.all([/* three requests */])
      dispatch({ type: REPORTS_RECEIVED, throughput, cycleTime, workload })

Each click starts its own thunk. Nothing checks whether the response still matches the range the user picked last. REPORTS_REQUESTED sets range to the newest choice, but REPORTS_RECEIVED replaces the data from whichever thunk finishes last.

Ignore responses the user has moved past

Drop the response when the store has moved on:

-  return async (dispatch) => {
+  return async (dispatch, getState) => {
     dispatch({ type: REPORTS_REQUESTED, projectKey, range })
@@
       ])
+      const current = getState().reports
+      if (current.projectKey !== projectKey || current.range !== range) return
       dispatch({ type: REPORTS_RECEIVED, throughput, cycleTime, workload })

The race still happens. The 90-day request still runs and still arrives last, and the app now ignores it.

Let verify wait for the requests

verify end waits for the app to settle before it decides. In 1.1.0 that includes a network domain: every fetch and XMLHttpRequest call the app started in the window must get its response. The wait needs requestWatchCollector. <Genie /> and the hub-served script register it for you. This app starts a bundled client with its own collector list, and that list leaves it out:

src/devtools/connect-genie.ts
-import { memoryCollector, perfCollector, timelineCollector } from 'genie-react/collectors'
+import { memoryCollector, perfCollector, requestWatchCollector, timelineCollector } from 'genie-react/collectors'
@@
     timelineCollector(),
+    requestWatchCollector(),
     reduxCollector(store, { name: 'app' }),

On 1.1.1 you can instead replace the collectors after reactCollector() with ...defaultAppCollectors({ reduxStore: store }) from genie-react/collectors, the same list <Genie /> registers.

Without requestWatchCollector, the verdict line lists only (react) and verify does not see pending requests. Asking for the domain with --domains react,network makes verify begin refuse every claim at once with exit code 4, before you click anything. Trimmed to the first claim:

npx genie-react verify begin --session upd-domains --name 'switch 90d then 7d' --domains react,network \
  --claim 'render ThroughputWidget max 3' --claim 'render ReportRangePicker min 1' --claim 'boundaries clean'
refused vfy_85facbbe-3967-4e6f-a3ad-e2bdf66dc77f "switch 90d then 7d"
  url "http://127.0.0.1:5251/reports"
  1 refused render ThroughputWidget max 3  capability_unavailable: The app does not report the network settle domain that --domains asks for. Add requestWatchCollector() to its Genie collectors, or leave network out of --domains.
      observed: {}
      evidence:{unsupportedDomains:[network],advertisedDomains:[react]},fix:{action:check-setup}
      fix: $ npx genie-react doctor --live --session upd-domains

Genie 1.1.0 accepted the domain and refused at verify end with not_quiescent. Every verdict below ran with the collector added, unless it says otherwise.

What verify can prove here

verify claims cover render counts, render causes, effect runs, error boundaries and Suspense fallbacks. None of them can say "the store holds the 7-day data". The closest claim is a render bound. On the shipped code, ThroughputWidget rendered 4 times during the two clicks. With the fix, which drops one RECEIVED, it rendered 3 times. So the claim is max 3:

npx genie-react verify begin --session upd-a --name 'switch 90d then 7d' \
  --claim 'render ThroughputWidget max 3' --claim 'render ReportRangePicker min 1' --claim 'boundaries clean'
agent-browser --session upd-a find role button click --name 'Last 90 days' && agent-browser --session upd-a find role button click --name 'Last 7 days'
npx genie-react verify end vfy_8cf7d291-bb3c-47ab-8e3e-ed9ff9d58d6a --session upd-a

Before the fix it exits 1, and failed the same way in all three runs:

fail vfy_8cf7d291-bb3c-47ab-8e3e-ed9ff9d58d6a "switch 90d then 7d"  9 commits, quiet after 2164 ms (react, network)
  1 fail render ThroughputWidget max 3  {renders:4,mounts:0,updates:4,remounts:0,semantics:exact,instances:1,activeInstances:1}

After the fix it exits 0 in all three runs, and the screen reads {"pressed":"Last 7 days","chartRange":"7d","bars":7}:

pass vfy_6ee2529e-a489-475f-8e86-da8ea34f19d8 "switch 90d then 7d"  7 commits, quiet after 1109 ms (react, network)
  1 pass render ThroughputWidget max 3  {renders:3,mounts:0,updates:3,remounts:0,semantics:exact,instances:1,activeInstances:1}

A slower stale response

Raise the 90-day latency to 5000 ms and revert the fix. React goes quiet long before the stale response lands, and verify end keeps waiting for the request. The buggy code fails with exit code 1:

fail vfy_e1330315-7fc8-4124-ba79-d2e9ab8935af "switch 90d then 7d"  13 commits, quiet after 5998 ms (react, network)
  1 fail render ThroughputWidget max 3  {renders:4,mounts:0,updates:4,remounts:0,semantics:exact,instances:1,activeInstances:1}

The window line shows the wait: waitedMs:5998, domains:{react:met,network:met}. Genie 1.0.2 waited for React only and passed this run. The app's client as shipped, without requestWatchCollector, still passes it on 1.1.0, with quiet after 1092 ms (react) and renders:3. Five seconds later its chart flipped to "chartRange":"90d","bars":13.

With the fix and the same 5000 ms delay, verify waits just as long and passes with exit code 0:

pass vfy_cbe487c4-c895-4a14-9ea7-5f760bb4b800 "switch 90d then 7d"  11 commits, quiet after 5071 ms (react, network)
  1 pass render ThroughputWidget max 3  {renders:3,mounts:0,updates:3,remounts:0,semantics:exact,instances:1,activeInstances:1}

When the slow request outlasts --timeout-ms, verify refuses instead of guessing. The buggy code with --timeout-ms 3000 exits 4:

refused vfy_6c5b8109-008d-4927-8749-48aec4306b9c "switch 90d then 7d"  9 commits, not quiet after 3096 ms (react, network)
  1 refused render ThroughputWidget max 3  not_quiescent: The app did not settle within the timeout (1 request is still in flight: GET http://127.0.0.1:5231/api/reports/throughput (3186 ms)), so later work could still change the answer.

The refusal names the request, and its fix line repeats the verify begin command with --timeout-ms 6000.

The stronger proof is the Redux log. After the fix, the same clicks with the 1200 ms delay produced the same late 90-day response at 1296.1 ms, still finishedAfterNewer: true. Only three reports/ actions followed:

{"matched":3,"records":[{"sequence":148,"type":"reports/REQUESTED","parentActionId":"redux-store:1/action:147","range":"90d","throughputRange":null},{"sequence":166,"type":"reports/REQUESTED","parentActionId":"redux-store:1/action:165","range":"7d","throughputRange":null},{"sequence":183,"type":"reports/RECEIVED","parentActionId":"redux-store:1/action:165","range":null,"throughputRange":"7d"}]}

Thunk 147 never dispatched RECEIVED. That is the fix working, read from the store instead of inferred from a render count.

When this approach does not fit

  • The request lane and the verify wait see fetch and XMLHttpRequest calls from the page. They do not see requests from workers, WebSocket or EventSource, and they cannot see what the app did with a response. Pair them with the store, component props or the screen.
  • parentActionId exists because the app's Redux store goes through Genie's Redux collector. With React state or a different store, use react_inspect_component on the component that renders the data.
  • react_render_causes did not tie the stale render to its action here. On ReportDataLoader it reported props.throughput as exact and the parent as inferred, with no Redux action named. The app's answer key explains that nested connect() components get that link only as inferred.
  • An AbortController per request is another common fix. This walkthrough did not test it.

See Verify a fix for claim forms, npx genie-react verify begin --help for --timeout-ms and --domains, and the Redux tools for redux_actions.

On this page