Make the Search Results Match the Query

Decide what you would build from the brief alone. Everything below it is available, but the exercise stops working if you open it first.

The brief you were given

A typeahead shows results for the wrong query intermittently. There is already a debounce. Make the displayed results provably correspond to the current input.

The trap — the wrong fix that looks right

Tracking a latestRequestId counter and ignoring responses whose id is lower, which is a real pattern and closes the ordering hole. What it does not do is stop the requests: every keystroke past the debounce still issues a full search, the server still executes all of them, and the client still pays the bandwidth on a mobile connection for results it will throw away. It also does not survive the component unmounting mid-flight, since the counter lives with the component. The correctness fix is genuine and it is half the job; without cancellation it turns a correctness bug into a load problem that only shows up in the server's metrics.