Back to feed
Dev.to
Dev.to
7/22/2026
301 duplicate IDs in the browser, 0 on the JVM: one real bug, end to end

301 duplicate IDs in the browser, 0 on the JVM: one real bug, end to end

Short summary

A real-world bug where gem IDs collided 301 times in the browser but zero times on the JVM, caused by browser clock clamping (a Spectre mitigation) breaking System.nanoTime() uniqueness assumptions. The fix replaced timestamp-based IDs with a simple synchronized counter. The author emphasizes that a fix is only done when a regression test exists in CI that would catch the original failure.

  • Browser clock clamping (Spectre mitigation) caused 301 ID collisions in TeaVM-compiled Java vs 0 on JVM
  • Fix: replace System.nanoTime()+random with a synchronized sequential counter
  • A fix is only complete when a CI test exists that would catch the original bug

Generated with AI, which can make mistakes.

Is this a good recommendation for you?

Comments

Failed to load comments. Please try again.

Explore more