Average Watch Time: Infinity

Easy

· Frontend

Incident

SEV-3

Time to fix: 10 min

Failing checks on the shipped build

  • zero viewers is zero average

    expected 0 but got null

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

Analytics dashboards

Inspired by every analytics dashboard that has proudly displayed "Infinity minutes" or "NaN%" on launch day, before any traffic arrived. Division needs a denominator.

metrics.js computes the overview cards.

Code map

// Overview card metrics.
exports.avgWatchMs = function (totalMs, viewers) {
  return Math.round(totalMs / viewers);
};

exports.clickRate = function (clicks, views) {
  return Math.round((clicks / views) * 1000) / 10;
};

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.

Average Watch Time: Infinity — JavaScript Bug Hunt

Inspired by every analytics dashboard that has proudly displayed "Infinity minutes" or "NaN%" on launch day, before any traffic arrived.

  • Language: JavaScript
  • Layer: Frontend
  • Difficulty: Easy
  • Concepts: Math, Division
  • Modelled on: Analytics dashboards
  • Visible tests: zero viewers is zero average; real traffic computes normally
  • 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

  • zero viewers is zero average — expected 0 but got null

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 analytics dashboard that has proudly displayed "Infinity minutes" or "NaN%" on launch day, before any traffic arrived. Division needs a denominator.

metrics.js computes the overview cards.

Bug report

BUG-INF · Reported by: dashboards

  • avgWatchMs(totalMs, viewers): 0 viewers -> 0
  • clickRate(clicks, views): percentage with ONE decimal; 0 views -> 0

Observed: fresh channels show "Infinity" and "NaN%" cards.

Logs

[cards] avg watch: Infinity min · CTR: NaN%

The code as shipped

src/stats/metrics.js (editable)

// Overview card metrics.
exports.avgWatchMs = function (totalMs, viewers) {
  return Math.round(totalMs / viewers);
};

exports.clickRate = function (clicks, views) {
  return Math.round((clicks / views) * 1000) / 10;
};

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.