Skip to content

fix(web): guard parent-issues search against out-of-order responses - #9733

Open
12mv2 wants to merge 1 commit into
makeplane:previewfrom
12mv2:fix/parent-issues-search-race
Open

fix(web): guard parent-issues search against out-of-order responses#9733
12mv2 wants to merge 1 commit into
makeplane:previewfrom
12mv2:fix/parent-issues-search-race

Conversation

@12mv2

@12mv2 12mv2 commented Sep 1, 2026

Copy link
Copy Markdown

Problem

The parent-issues search effect writes the response directly into state with no cleanup:

projectService
  .projectIssuesSearch(workspaceSlug, projectId, { search: debouncedSearchTerm, ... })
  .then((res) => setIssues(res))

debouncedSearchTerm is 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 calls setIssues last 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 .finally has the same issue: a stale response can clear isSearching/isLoading while a newer request is still in flight.

react-hooks/exhaustive-deps is 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.

let ignore = false;
// ...
.then((res) => { if (!ignore) setIssues(res); })
.finally(() => { if (ignore) return; setIsSearching(false); setIsLoading(false); });

return () => { ignore = true; };

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

  • Scoped to one file; no API or type changes.
  • I wasn't able to run the full local stack (it needs Docker + Postgres + Redis per CONTRIBUTING), so this is verified by inspection and parse-checked only — I'm relying on the PR build/lint workflow. Happy to adjust if you'd prefer a different guard style, or to open an issue first if that's the process you'd rather follow.
  • Found while testing a static-analysis rule I'm building for this class of effect bug.

Summary by CodeRabbit

  • Bug Fixes
    • Improved issue search reliability by ignoring outdated results from previous searches.
    • Prevented loading indicators and results from updating after the search view is closed or refreshed.

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.
Copilot AI lite review requested due to automatic review settings September 1, 2026 17:36
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ignore flag for the parent-issues search request lifecycle.
  • Guard setIssues so stale responses don’t overwrite newer search results.
  • Guard setIsSearching/setIsLoading so 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.

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 67096e21-3961-4c57-ae52-dcf0e30ff771

📥 Commits

Reviewing files that changed from the base of the PR and between 12eb601 and 777c7ae.

📒 Files selected for processing (1)
  • apps/web/core/components/issues/parent-issues-list-modal.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The 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.

Changes

Parent issue search

Layer / File(s) Summary
Guard asynchronous search updates
apps/web/core/components/issues/parent-issues-list-modal.tsx
The effect tracks whether its request is stale. Result and loading-state updates run only for current requests. Cleanup marks the request as ignored.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 777c7

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: sriramveeraghanta

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: guarding the parent-issues search against out-of-order responses.
Description check ✅ Passed 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 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

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.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants