-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix hard crash when closing budget thats synced to cloud file #4322
Fix hard crash when closing budget thats synced to cloud file #4322
Conversation
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Bundle Stats — desktop-clientHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger
Smaller
Unchanged
|
Bundle Stats — loot-coreHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset No files were changed View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger No assets were bigger Smaller No assets were smaller Unchanged
|
WalkthroughThe changes modify the dependency array within a useEffect hook in the AppInner function of App.tsx. Specifically, the cloudFileId variable has been removed from the list to prevent a hard crash when closing the budget in an Electron environment. A comment was added to document this specific change. All existing logic—including app update handling, connection initialization, loading of global preferences, and budget state management—remains unaltered. No modifications were made to the other useEffect hooks, the overall component structure, or to the declarations of exported or public entities. Possibly related PRs
Suggested labels
Suggested reviewers
Tip 🌐 Web search-backed reviews and chat
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/desktop-client/src/components/App.tsx (1)
127-129
: Consider a more robust solution.Instead of removing the dependency, consider these alternatives:
- Track the budget closure state using a ref
- Add a guard clause in the init function
- Restructure the initialization logic
Here's an example implementation using a ref:
function AppInner() { const [budgetId] = useMetadataPref('id'); const [cloudFileId] = useMetadataPref('cloudFileId'); + const isClosingRef = useRef(false); useEffect(() => { async function init() { + if (isClosingRef.current) { + return; + } // ... rest of init logic } initAll().catch(showErrorBoundary); - // Removed cloudFileId from dependencies to prevent hard crash when closing budget in Electron - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [dispatch, showErrorBoundary, t]); + }, [dispatch, showErrorBoundary, t, cloudFileId]); + // Update the ref when closing budget + useEffect(() => { + const handleCloseBudget = () => { + isClosingRef.current = true; + }; + send('subscribe-to-event', 'close-budget', handleCloseBudget); + return () => { + send('unsubscribe-from-event', 'close-budget', handleCloseBudget); + }; + }, []); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
upcoming-release-notes/4322.md
is excluded by!**/*.md
📒 Files selected for processing (1)
packages/desktop-client/src/components/App.tsx
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Functional
- GitHub Check: Visual regression
🔇 Additional comments (1)
packages/desktop-client/src/components/App.tsx (1)
127-129
: Immediate fix approved but introduces technical debt.While removing
cloudFileId
from the dependency array fixes the crash, it violates React's exhaustive dependencies rule sincecloudFileId
is used within the effect (line 111). This creates technical debt that should be addressed in the future.
I have not been able to get the appimage to crash. Everything else seems fine too |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The hard crash was introduced here: #4124
Cause:
When you close a cloud budget the useEffect that calls
init
is triggered because of the cloudFileId. The init triggers a load budget call - so we're loading the budget while we're closing it, causing the app to crash. It was crashing trying to get the global spreadsheet when it was unloaded.