Testing on bad networks

Play this lesson

It worked in the office

Remy's office wifi has a 5 ms ping and no loss. Every Shard Garden test passes there.

Then a player on a train writes in: seeds vanish, and races freeze. The office never showed it.

A bad network on demand

Chrome DevTools can add custom network profiles. Each can set latency in milliseconds, a packet loss percentage, a queue length, and packet reordering.

Remy makes three: home (40 ms), mobile (150 ms, 2% loss) and train (300 ms, 10% loss, reordering on).

Quick check

Which of Remy's settings tests what happens when packets arrive in the wrong order?

  1. Packet reordering
  2. Latency
  3. Queue length
Show the answer

Packet reordering

Reordering delivers some packets after later ones, which is exactly what a train's patchy signal does.

What the train found

On the train profile, three bugs appear: corrections snap instead of smoothing, a lost race start leaves a player stuck, and some saves happen twice.

Bug hunt

On the train profile, some saves happen twice. Which earlier lesson has the fix?

  1. Idempotency: retries carry the same key, so the server applies them once
  2. Caching
  3. Sharding
Show the answer

Idempotency: retries carry the same key, so the server applies them once

A lost reply makes the app retry. With an idempotency key, the second try returns the first result instead of saving again.

In every test run

Remy runs the game's end-to-end tests under the train profile too. A change that only breaks on a bad network now fails a test, before players see it.

Quick check

If the code is correct, testing on office wifi is enough.

Show the answer

False

Some bugs only appear with delay, loss or reordering. Correct code can still handle a bad network badly.

On the studio board

The studio adds a decision to the board:

Every release is played on the train profile, 300 ms with 10% loss, before it ships.

Shard Garden now plays across continents: UDP where loss is fine, snapshots and interpolation, prediction and reconciliation, rewinds for fair catches, rated races and nearby servers.

Bolt says: Boss time: one quiz across the whole Netcode stage.

Fact-checked 12 October 2026