fix(result-set): bound and clean up filter/sort render polls - #2025
Merged
openai0229 merged 4 commits intoJul 24, 2026
Conversation
useFilterAndSort polled VTable with setInterval(100ms) until the row list changed, then clearInterval. If the list never changed (empty result, same-row filter) or the component unmounted mid-poll, the interval ran forever and fired setState on an unmounted component. The timerId was a local with no ref and no unmount cleanup. Add a pollTimerIdsRef, a pollUntilRowNumbersChange helper with a MAX_POLL_ITERATIONS cap (100 x 100ms = 10s), and an unmount effect that clears active timers. Route all four poll sites through it. Fixes OtterMind#2023 Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
Author
|
@openai0229 hi, are you real people? can you add my wechat: aias00 |
openai0229
approved these changes
Jul 24, 2026
openai0229
left a comment
Contributor
There was a problem hiding this comment.
Reviewed all four poll sites and the timer lifecycle. The bounded polling and Set-based cleanup fix the leak; I also added cleanup when tableInstance is replaced (commit 039924f) so old-instance timers cannot survive without an unmount. Focused ESLint, the combined Community build, and updated required checks pass. No blocking issues remain.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related issue
Closes #2023
Summary
useFilterAndSortpolled VTable withsetInterval(..., 100)until therendered
CHAT2DB_ROW_NUMBERlist changed, thenclearInterval. If thelist never changed (empty result set, a filter yielding the same rows, or
the component unmounting mid-poll), the interval ran forever. The
timerIdwas a local variable inside each handler closure — there was noref and no unmount cleanup — so after unmount the interval kept firing and
called
setState/table APIs on an unmounted component, leaking memory.The same pattern appeared at four sites (lines 187/219/250/309).
Changes:
pollTimerIdsRefthat tracks active poll timers.pollUntilRowNumbersChange(before, onSettled)helper with aMAX_POLL_ITERATIONScap (100 iterations x 100ms = 10s) so a pollcannot run forever when the row list never changes; each timer is
registered and unregistered on settle/cap.
useEffectthat clears every active timer.clearAllFilters) through the helper.
The cap value (
MAX_POLL_ITERATIONS = 100) is chosen generously: thepolls run every 100ms and VTable render settles in milliseconds, so 10s
is far above the normal settle time while still bounding the leak. It is
a single named constant and trivial to tune.
Affected surfaces
Verification
npx tsc --noEmit -p chat2db-community-client/tsconfig.json— no errors reported foruseFilterAndSort.tsx.npx eslint src/blocks/SearchResult/components/ResultSetTable/hooks/useFilterAndSort.tsx— no errors.setIntervalremains (the helper's) and all four call sites now callpollUntilRowNumbersChange(lines 224/250/275/328).Risk and compatibility
sortAfter/filterAfter, clears the timer). Only the previously-leaking paths are bounded and cleaned up.Reviewer map
useFilterAndSort.tsx— newMAX_POLL_ITERATIONSconstant (line 33),pollTimerIdsRef+pollUntilRowNumbersChangehelper + unmountuseEffect(lines 52-83), and the four call sites (224/250/275/328) replacing the inlinesetIntervalblocks.Contributor declaration
AI assistance: The fix, verification, and PR description were produced with Claude Code assistance.