Schrödinger's Follower Count — JavaScript Bug Hunt

Inspired by the follower counters of large social networks, which read from whichever replica answers first — so refreshing your profile makes the number…

  • Language: JavaScript
  • Layer: Backend
  • Difficulty: Medium
  • Concepts: Consistency, Caching
  • Modelled on: Social counters
  • Visible tests: lagging replicas never lower the number; genuinely higher counts show
  • Reward: 50 XP for a complete fix

Briefing

Inspired by the follower counters of large social networks, which read from whichever replica answers first — so refreshing your profile makes the number bounce down and back up. Displayed counters should be monotonic: never show fewer than the user has already seen.

counter.js picks what to display.

Bug report

BUG-BOUNCE · Reported by: creator support (screenshots of "losing" followers)

nextDisplay(previousShown, freshReads):

  • take the max of the fresh replica reads
  • never display LESS than previousShown (replicas lag; going down is noise)
  • returns the new displayed value

Observed: the counter renders whatever the slowest replica said.

Logs

[profile] shown 10,204 -> refresh -> 10,197 -> refresh -> 10,205

The code as shipped

src/social/counter.js (editable)

// Chooses the follower count to display.
exports.nextDisplay = function (previousShown, freshReads) {
  return freshReads[freshReads.length - 1];
};

Open the hunt to edit the files, run the visible tests and submit against the hidden ones. More JavaScript bug hunts.