@@ -6,6 +6,7 @@ use crate::{
66use bumpalo::Bump;
77use fxhash::{FxHashMap, FxHashSet};
88use std::sync::atomic::{AtomicUsize, Ordering};
9+use std::u32;
910use wasm_bindgen::prelude::*;
1011
1112static ID_COUNTER: AtomicUsize = AtomicUsize::new(0);
@@ -101,7 +102,9 @@ impl CachedSet {
101102 }
102103
103104 fn next_id(&mut self) -> CacheId {
104− CacheId(ID_COUNTER.fetch_add(1, Ordering::AcqRel) as u32)
105+ let next = ID_COUNTER.fetch_add(1, Ordering::AcqRel) as u32;
106+ let next = if next == u32::MAX { None } else { Some(next) };
107+ CacheId(next.expect_throw("ID_COUNTER overflowed"))
105108 }
106109
107110 pub(crate) fn insert<F>(cx: &mut RenderContext, f: F) -> CacheId