Crossing the Date Line

Medium

· Backend

Incident

SEV-1

BUG-DATELINE

Priority: Critical · reported by flight test

Time to fix: 20 min

Failing checks on the shipped build

  • crossing the antimeridian takes the short way

    should wrap eastward, not go the long way round: expected 2 but got -358

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
  4. Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

Inspired by

F-22 Raptor · 2007

Modelled on the F-22 Raptor date-line incident (February 2007): a flight of six aircraft crossed the 180th meridian on the way to Okinawa and every onboard computer crashed at once, losing navigation and fuel systems. The jets had to follow their tankers back by sight.

navigation.js computes the shortest longitude difference between two points and does not handle the wrap at ±180.

Fix longitudeDelta so it returns the shortest signed difference, always in the range (-180, 180].

Code map

// Shortest signed longitude difference, in degrees.
exports.longitudeDelta = function (from, to) {
  return to - from;
};

Sign in to edit the file, run the tests and submit a fix

A free account — no card, no trial clock. You come straight back here.

Crossing the Date Line — JavaScript Bug Hunt

Modelled on the F-22 Raptor date-line incident (February 2007): a flight of six aircraft crossed the 180th meridian on the way to Okinawa and every onboard…

  • Language: JavaScript
  • Layer: Backend
  • Difficulty: Medium
  • Concepts: Coordinates, Wraparound
  • Modelled on: F-22 Raptor · 2007
  • Visible tests: an ordinary eastward hop; crossing the antimeridian takes the short way
  • Reward: 50 XP for a complete fix

Incident

  • Severity: SEV-1 (priority: Critical)
  • Ticket: BUG-DATELINE
  • Reported by: flight test
  • Time to fix: 20 minutes, the target for a medium incident

Failing checks on the shipped build

  • crossing the antimeridian takes the short way — should wrap eastward, not go the long way round: expected 2 but got -358

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
  4. Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

Briefing

Modelled on the F-22 Raptor date-line incident (February 2007): a flight of six aircraft crossed the 180th meridian on the way to Okinawa and every onboard computer crashed at once, losing navigation and fuel systems. The jets had to follow their tankers back by sight.

navigation.js computes the shortest longitude difference between two points and does not handle the wrap at ±180.

Fix longitudeDelta so it returns the shortest signed difference, always in the range (-180, 180].

Bug report

BUG-DATELINE · Priority: Critical · Reported by: flight test

longitudeDelta(from, to) returns the shortest signed difference in degrees:

  • positive when heading east, negative when heading west
  • always within (-180, 180]

Observed: crossing the antimeridian from 179 to -179 reports -358 instead of the correct +2, which sends the whole navigation solution off the map.

Logs

[nav] delta=-358.0 from=179.0 to=-179.0
[nav] course solution rejected; system reset

The code as shipped

src/nav/navigation.js (editable)

// Shortest signed longitude difference, in degrees.
exports.longitudeDelta = function (from, to) {
  return to - from;
};

Read-only context: src/nav/SPEC.js.

Open the hunt to start the incident clock, edit the files, run the visible tests and submit against the hidden ones, then write the root cause down. More JavaScript bug hunts.