Ten Seconds to Next Episode

Easy

· Frontend

Incident

SEV-3

Time to fix: 10 min

Failing checks on the shipped build

  • shows the full window at the start

    9.2s remaining rounds up to 10: expected 10 but got 9

  • shows 1 for the final second

    expected 1 but got 0

  • never launches early

    9.1s is too early: expected false but got true

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 value the screen shows back through the state and the pure helpers that compute it; the view is usually only the messenger.
  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

Netflix autoplay

Inspired by every streaming service's autoplay countdown. The "Next episode in N…" overlay is skipping straight from 2 to launch, and sometimes fires the next episode a full second early.

Both symptoms come from the same two lines in countdown.js.

Code map

// Autoplay countdown for the next-episode overlay.
var WINDOW_MS = 10000;

exports.secondsLeft = function (startMs, nowMs) {
  var remaining = WINDOW_MS - (nowMs - startMs);
  if (remaining <= 0) return 0;
  return Math.floor(remaining / 1000);
};

exports.shouldLaunch = function (startMs, nowMs) {
  return nowMs - startMs > WINDOW_MS - 1000;
};

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.

Ten Seconds to Next Episode — JavaScript Bug Hunt

Inspired by every streaming service's autoplay countdown. The "Next episode in N…" overlay is skipping straight from 2 to launch, and sometimes fires the…

  • Language: JavaScript
  • Layer: Frontend
  • Difficulty: Easy
  • Concepts: Timers, Off-by-one
  • Modelled on: Netflix autoplay
  • Visible tests: shows the full window at the start; shows 1 for the final second; never launches early
  • Reward: 50 XP for a complete fix

Incident

  • Severity: SEV-3
  • Time to fix: 10 minutes, the target for an easy incident

Failing checks on the shipped build

  • shows the full window at the start — 9.2s remaining rounds up to 10: expected 10 but got 9
  • shows 1 for the final second — expected 1 but got 0
  • never launches early — 9.1s is too early: expected false but got true

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 value the screen shows back through the state and the pure helpers that compute it; the view is usually only the messenger.
  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

Inspired by every streaming service's autoplay countdown. The "Next episode in N…" overlay is skipping straight from 2 to launch, and sometimes fires the next episode a full second early.

Both symptoms come from the same two lines in countdown.js.

Bug report

BUG-9001 · Reported by: playback UX

Spec (10s window):

  • secondsLeft(startMs, nowMs) shows the CEILING of the remaining time: at 9.2s remaining it must show 10, at 0.5s it shows 1, at 0 exactly it shows 0.
  • shouldLaunch(startMs, nowMs) is true only once the full window has elapsed.

Observed: the overlay shows 9 immediately, and launch fires at 9.1s.

Logs

[autoplay] t+0.0s label=9 (expected 10)
[autoplay] launched at t+9.1s (expected t+10.0s)

The code as shipped

src/player/countdown.js (editable)

// Autoplay countdown for the next-episode overlay.
var WINDOW_MS = 10000;

exports.secondsLeft = function (startMs, nowMs) {
  var remaining = WINDOW_MS - (nowMs - startMs);
  if (remaining <= 0) return 0;
  return Math.floor(remaining / 1000);
};

exports.shouldLaunch = function (startMs, nowMs) {
  return nowMs - startMs > WINDOW_MS - 1000;
};

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.