feat: Fix login, abort all calls on disconnect#726
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR introduces a system to track and abort pending async operations across the application. A new abort registry module provides core infrastructure; Redux middleware automatically registers promise-like abortables; auth state gains a partial reset action; ConnectNode components integrate abort calls on disconnect and reconnect; and LayoutEnhanced restricts URL-driven login to mount-time only. ChangesAbort Tracking System for Pending Operations
🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/LayoutEnhanced.tsx (1)
53-160:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winAdd a ref guard to prevent duplicate login dispatches in React Strict Mode.
In React 19 with StrictMode enabled (as configured in
src/index.tsx), auseEffectwith an empty dependency array[]and no cleanup function runs twice during development: setup → cleanup → setup. This causes your login dispatches and tracking calls to execute twice unnecessarily.Use a
useRefflag to ensure the effect body runs only once per component lifetime:Suggested patch
import { useEffect } from 'react'; +import { useRef } from 'react'; @@ const LayoutEnhanced = () => { + const didRunUrlLoginRef = useRef(false); @@ useEffect(() => { + if (didRunUrlLoginRef.current) return; + didRunUrlLoginRef.current = true; + if (!apiEndpoint) return; if (loginData.apiEndpoint === apiEndpoint && loginData.apiToken === apiToken) return; @@ - // run only on first mount — URL-driven auto-login + // run only once per component lifetime — URL-driven auto-login }, []);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/LayoutEnhanced.tsx` around lines 53 - 160, The effect in LayoutEnhanced.tsx that performs the URL-driven login (the useEffect containing the nested useNode async and calls like authActions.useNodeData, authActionsAsync.loginThunk, and trackGoal) can run twice in React Strict Mode; add a useRef boolean (e.g., ranRef) at the top of the component and check it at the start of that useEffect so the body returns immediately if ranRef.current is true, and set ranRef.current = true the first time the effect runs (so the subsequent duplicate run is no-op). Ensure the guard covers the entire effect (including dispatches and trackGoal) so duplicate login dispatches are prevented.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/ConnectNode/modal.tsx`:
- Around line 260-263: There is a dangling identifier token "abortAllPending"
after the call to dispatch(nodeActions.resetState()) which is an
unused-expression and may fail linting; remove that stray token so the code
reads abortAllPending(); dispatch(authActions.resetState());
dispatch(nodeActions.resetState()); (or keep the existing abortAllPending() call
only once) and ensure proper semicolons/line breaks around abortAllPending,
dispatch(authActions.resetState) and dispatch(nodeActions.resetState) to avoid
the leftover identifier.
---
Outside diff comments:
In `@src/LayoutEnhanced.tsx`:
- Around line 53-160: The effect in LayoutEnhanced.tsx that performs the
URL-driven login (the useEffect containing the nested useNode async and calls
like authActions.useNodeData, authActionsAsync.loginThunk, and trackGoal) can
run twice in React Strict Mode; add a useRef boolean (e.g., ranRef) at the top
of the component and check it at the start of that useEffect so the body returns
immediately if ranRef.current is true, and set ranRef.current = true the first
time the effect runs (so the subsequent duplicate run is no-op). Ensure the
guard covers the entire effect (including dispatches and trackGoal) so duplicate
login dispatches are prevented.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 704bfdb4-082c-4414-b652-fe91689674c8
📒 Files selected for processing (6)
src/LayoutEnhanced.tsxsrc/components/ConnectNode/index.tsxsrc/components/ConnectNode/modal.tsxsrc/store/abortRegistry.tssrc/store/index.tssrc/store/slices/auth/index.ts
🔎 Trivy Security Report
|
Changelog:
Summary by CodeRabbit
Bug Fixes
Performance
New Features