Summary of What Needs to be Done
src/utils/routePrefetch.js uses a module-level prefetchCache Map to store dynamic import promises. There is no cap on the number of entries — over time, as users navigate through the app and different routes are prefetched, the Map grows indefinitely. In long-running sessions or SPAs, this causes unbounded memory growth.
Changes
Add a MAX_PREFETCH_CACHE_SIZE constant (e.g., 50) and evict the oldest entry when the cap is exceeded, similar to the fix already applied in prefetchUtils.js.
Impact
- Memory leak: The
prefetchCache Map grows without bound as users navigate, eventually exhausting browser memory in long-running sessions.
- Note:
prefetchUtils.js already has this fix applied; routePrefetch.js is the older module that needs the same treatment.
Please assign this task to me.
Summary of What Needs to be Done
src/utils/routePrefetch.jsuses a module-levelprefetchCacheMap to store dynamic import promises. There is no cap on the number of entries — over time, as users navigate through the app and different routes are prefetched, the Map grows indefinitely. In long-running sessions or SPAs, this causes unbounded memory growth.Changes
Add a
MAX_PREFETCH_CACHE_SIZEconstant (e.g., 50) and evict the oldest entry when the cap is exceeded, similar to the fix already applied inprefetchUtils.js.Impact
prefetchCacheMap grows without bound as users navigate, eventually exhausting browser memory in long-running sessions.prefetchUtils.jsalready has this fix applied;routePrefetch.jsis the older module that needs the same treatment.Please assign this task to me.