Skip to content

Conversation

@kiwina
Copy link
Contributor

@kiwina kiwina commented Jun 2, 2025

PR for RooTips setTimeout Leak (RooTips_37)

This PR addresses the uncleaned setTimeout in the RooTips component, as identified in leak-report/guaranteed/RooTips_37.md.

Description

The useEffect hook in RooTips.tsx correctly clears its setInterval but fails to clear a setTimeout that is scheduled within the interval's callback. If the component unmounts or the cycle prop changes while this setTimeout is pending, it can lead to attempts to update state on an unmounted component.

This patch implements the suggested fix from the leak report: storing the timeoutId from setTimeout and clearing it in the useEffect cleanup function.

Related Bug Report

#4234

Changes

  • Modified webview-ui/src/components/welcome/RooTips.tsx:
    • Declared timeoutId within the useEffect scope.
    • Assigned the ID returned by setTimeout to timeoutId.
    • Added clearTimeout(timeoutId) to the useEffect cleanup function.

How to Test

  1. Render the RooTips component with cycle={true}.
  2. Allow the tip to cycle at least once so the setTimeout is scheduled.
  3. Unmount the RooTips component (or change the cycle prop) before the 1-second fade duration (controlled by the setTimeout) completes.
  4. Verify that no React warnings about state updates on unmounted components appear in the console.

Important

Fixes uncleaned setTimeout in RooTips.tsx to prevent state updates on unmounted components.

  • Behavior:
    • Fixes uncleaned setTimeout in RooTips.tsx by storing timeoutId and clearing it in useEffect cleanup.
    • Prevents state updates on unmounted components when cycle prop changes or component unmounts.
  • Testing:
    • Render RooTips with cycle={true} and unmount before setTimeout completes to ensure no React warnings.

This description was created by Ellipsis for 8cb42dd. You can customize this summary. It will automatically update as commits are pushed.

Closes: #4234

@kiwina kiwina requested review from cte and mrubens as code owners June 2, 2025 05:40
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Jun 2, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jun 2, 2025
@daniel-lxs
Copy link
Member

daniel-lxs commented Jun 2, 2025

Thank you @kiwina

LGTM!

@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Needs Review] in Roo Code Roadmap Jun 2, 2025
@daniel-lxs daniel-lxs changed the title fix: auto patch for RooTips_37 fix(RooTips): Clear setTimeout in useEffect cleanup to prevent state updates on unmounted components Jun 3, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 4, 2025
@mrubens mrubens merged commit 815a0fb into RooCodeInc:main Jun 4, 2025
18 checks passed
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jun 4, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jun 4, 2025
SmartManoj pushed a commit to SmartManoj/Raa-Code that referenced this pull request Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer PR - Needs Review size:S This PR changes 10-29 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

fix: Uncleaned setTimeout in RooTips component (RooTips_37)

3 participants