fix: prevent infinite loading loop on skills page #90
+3
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the infinite loading loop on the
/skillspage when a user scrolls to the bottom and stays idle.Problem
The IntersectionObserver for infinite scroll was firing continuously while data was being loaded, causing an endless cycle of WebSocket queries to the Convex backend.
The loop:
Solution
Added
isLoadingMoreguard to the IntersectionObserveruseEffect. The observer now won't be set up while a request is in progress, breaking the infinite loop.Changes in
src/routes/skills/index.tsx:useEffect(() => { + // Don't set up observer while loading to prevent infinite request loop - if (!canLoadMore || typeof IntersectionObserver === 'undefined') return + if (!canLoadMore || isLoadingMore || typeof IntersectionObserver === 'undefined') return // ... observer setup - }, [canLoadMore, loadMore]) + }, [canLoadMore, isLoadingMore, loadMore])Related Issues
Additional Context: Sorting Issue (#85)
While investigating, I found that sorting happens client-side (
lines 163-189). The server always returns data sorted byupdatedAtregardless of user's sort selection.This causes items to "jump around" when new pages load, which contributed to the infinite loop via re-renders.
Why server-side sorting is complex
Current indexes don't support both soft-delete filtering AND custom sorting:
by_active_updatedby_stats_downloadsA full fix would require new composite indexes:
Happy to help implement this if maintainers are interested!
Testing
Greptile Overview
Greptile Summary
This PR fixes an infinite loading loop on the
/skillsroute by preventing theIntersectionObserverinfinite-scroll hook from being (re)attached while an in-flight page load is ongoing. Concretely, it adds anisLoadingMoreguard to the observeruseEffectand includesisLoadingMorein the dependency array, avoiding repeatedloadMore()calls triggered by re-renders while the sentinel remains intersecting.Confidence Score: 5/5
/skillsinfinite-scroll observer effect, and adds a straightforward guard plus dependency update to prevent repeated pagination triggers during an active load. No API contracts or data handling semantics change.(2/5) Greptile learns from your feedback when you react with thumbs up/down!
Context used:
dashboard- AGENTS.md (source)