fix(web): guard parent-issues search against out-of-order responses - #9733
fix(web): guard parent-issues search against out-of-order responses#973312mv2 wants to merge 1 commit into
Conversation
The search effect writes the response straight into state with no cleanup. Since debouncedSearchTerm is reactive, a slower earlier request can resolve after a later one and call setIssues last, leaving the list showing results for a query the user has already moved past until the next keystroke.
|
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a race condition in the web app’s parent-issue selector modal where out-of-order async search responses could overwrite newer results (and incorrectly toggle loading/searching state). It does this by scoping an “ignore stale responses” flag to the useEffect lifecycle and no-op’ing any resolved handlers after cleanup.
Changes:
- Add an effect-scoped
ignoreflag for the parent-issues search request lifecycle. - Guard
setIssuesso stale responses don’t overwrite newer search results. - Guard
setIsSearching/setIsLoadingso stale requests can’t clear loading state for an in-flight newer request, and add cleanup to mark prior requests stale.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe parent issue search effect now ignores results and loading-state updates from stale requests after reruns or unmounts. Cleanup marks the active request as ignored before later responses resolve. ChangesParent issue search
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change prevents outdated parent-issue search responses from replacing newer results or prematurely ending the loading state. It is localized to the search UI and introduces no actionable merge-blocking risk beyond normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description explains the race condition, the cleanup-scoped ignore-flag fix, reproduction steps, scope, and verification status. It does not use every template section explicitly, and the Type of Change selection is missing, but the required technical context is mostly complete.
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
The parent-issues search effect writes the response directly into state with no cleanup:
debouncedSearchTermis reactive, so a new request starts whenever the term changes. Debouncing narrows the window but doesn't close it — if an earlier, slower request resolves after a later one, the older response callssetIssueslast and the list shows results for a query the user has already moved past. It stays wrong until the next keystroke, with no error.The
.finallyhas the same issue: a stale response can clearisSearching/isLoadingwhile a newer request is still in flight.react-hooks/exhaustive-depsis satisfied by this code, which is part of why it's easy to miss in review.Fix
Standard cleanup-scoped ignore flag. The effect's cleanup marks in-flight responses stale, and both continuations no-op for superseded requests.
No behaviour change for the common path — only stale responses are dropped.
Reproduction
Open the parent-issue selector and type a query that returns slowly, then quickly refine it. With network throttling the earlier response can land last, leaving results that don't match the input.
Notes
Summary by CodeRabbit