Handling Out-of-Order Network Responses in Search Interfaces

You type "react" into a search box. Results for "react" appear for a split second, then the list flips to results for "re". Nothing is wrong with your backend and your query was correct. You just met one of the most common bugs in interactive web applications: out-of-order network responses.

This guide explains why responses arrive in a different order than requests were sent, how to reproduce the problem reliably, and how to fix it with patterns that work in plain JavaScript, React, and TanStack Query. It also covers server-side details, accessibility, and testing, which most tutorials skip.

Why Network Responses Arrive Out of Order

HTTP gives you no guarantee that responses return in the order requests were sent. Even if your client sends request A before request B, B can finish first for many ordinary reasons:

  • Different workloads. A short query like "re" may match thousands of records and take longer than a specific query like "react hooks", which matches a handful.
  • Multiple server instances. Requests can be routed to different instances or regions with different load, cache state, or cold-start behavior.
  • Connection behavior. With HTTP/2 or HTTP/3, requests share a connection but are processed independently. With HTTP/1.1, browsers open several connections per host, so requests can complete in any order.