generated from cording12/next-fast-turbo
-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Description
Description
The onboarding tour component uses recursive setTimeout calls to retry finding target elements, but only the initial setTimeout is cleaned up on unmount. The inner retry setTimeout calls (line ~575, ~480) are never cancelled, which can cause state updates on unmounted components.
Files to Update
surfsense_web/components/onboarding-tour.tsx(lines ~558–581 and ~478–488)
What to Do
Use a ref to track whether the effect is still active, and skip state updates after cleanup:
// For the checkAndStartTour retry pattern (lines ~558-581):
useEffect(() => {
let cancelled = false;
const checkAndStartTour = () => {
if (cancelled) return;
const connectorEl = document.querySelector(...);
// ...
if (connectorEl && documentsEl && inboxEl) {
// start tour
} else {
setTimeout(checkAndStartTour, 200); // recursive retry
}
};
const timer = setTimeout(checkAndStartTour, 500);
return () => {
cancelled = true;
clearTimeout(timer);
};
}, [/* deps */]);Apply the same cancelled flag pattern to the updateTarget retry logic (lines ~478–488). The flag ensures that after cleanup, no further setTimeout callbacks will attempt DOM queries or state updates.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers