lecture 15 of 190 completed

Requests that answer out of order

A late reply can replace newer results. Send both requests, control which reply lands last, and wait for both before you check.

What you'll learn

  • Why a test that waits for each reply can never see replies out of order
  • How to hold replies in a test and release them in the order you choose
  • Why you wait for every reply before you check the page

Ferry Times has a harbour search. You type Oban and press Enter. Then you change your mind, type Mull and press Enter again. The page sends two requests. A request is the message the page sends to the server. Each request gets a reply, a moment later.

Most of the time the Oban reply comes back first, then the Mull reply. The page shows the departures from Mull, which is right. Now picture a slow connection. The Mull reply arrives first. The Oban reply arrives one second later, and the page draws it. The search box says Mull, and the list shows the times from Oban. A passenger reads the wrong times and misses the ferry.

full course

Keep reading with the full course

The Foundations track and the first lessons in each framework are free. This lesson needs full course access. A course plan includes all lessons for Playwright, Cypress and Selenium.

See course plans →