The Upvote That Counted Twice

Easy

· Frontend

Incident

SEV-3

Time to fix: 10 min

Failing checks on the shipped build

  • one user's repeated upvotes count once

    expected 1 but got 3

  • last action per user wins

    expected -1 but got 0

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

Reddit

Inspired by vote-count drift on link aggregators. A user who taps up, then down, then up again must count as one final upvote — the tally is per user, last action wins.

The event fold in votes.js sums raw events instead.

Code map

// Folds vote events into a score. dir is +1 or -1.
exports.tally = function (events) {
  var score = 0;
  for (var i = 0; i < events.length; i++) {
    score += events[i].dir;
  }
  return score;
};

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.

The Upvote That Counted Twice — JavaScript Bug Hunt

Inspired by vote-count drift on link aggregators. A user who taps up, then down, then up again must count as one final upvote — the tally is per user, last…

  • Language: JavaScript
  • Layer: Frontend
  • Difficulty: Easy
  • Concepts: Dedupe, State
  • Modelled on: Reddit
  • Visible tests: one user's repeated upvotes count once; last action per user wins; independent users sum
  • 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

  • one user's repeated upvotes count once — expected 1 but got 3
  • last action per user wins — expected -1 but got 0

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 vote-count drift on link aggregators. A user who taps up, then down, then up again must count as one final upvote — the tally is per user, last action wins.

The event fold in votes.js sums raw events instead.

Bug report

BUG-UPV2 · Reported by: ranking team

tally([u1:+1, u1:-1, u1:+1]) must be +1 (one user, final state up). We compute +1 -1 +1 = ... well, +1 — but tally([u1:+1, u1:+1]) gives +2, and rage-tappers are minting infinite karma.

Logs

[votes] post 991: 3 users, tally=17

The code as shipped

src/feed/votes.js (editable)

// Folds vote events into a score. dir is +1 or -1.
exports.tally = function (events) {
  var score = 0;
  for (var i = 0; i < events.length; i++) {
    score += events[i].dir;
  }
  return score;
};

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.