-
-
Notifications
You must be signed in to change notification settings - Fork 8
fix: Lazy initialize Firebase only when needed #9
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
base: main
Are you sure you want to change the base?
Conversation
- Added slider-based year range filter to replace individual year selection - Implemented draggable thumbs for min and max year selection - Added visual feedback during drag operations - Removed redundant UI elements for cleaner interface - Support for future years up to current year + 10 Fixes CodeCompasss#6
- Add validation check for required Firebase config values - Create mock services when Firebase is not configured - Add helper function to check Firebase initialization status - Update auth service to handle uninitialized Firebase gracefully - Add detailed warning messages for development mode - Prevent app crashes when Firebase config is missing Fixes #[issue-number]
- Added lazy initialization for Firebase services - Created getter functions to ensure Firebase is initialized only when accessed - Improved error handling and development experience - Added proper mock implementations for development mode - Updated auth.ts to use new getter functions Fixes CodeCompasss#7
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.
Pull Request Overview
This PR implements lazy initialization for Firebase services to ensure they are configured only when needed, while also introducing mock implementations and improved error handling in development mode.
- Introduces lazy initialization and getter functions for Firebase services.
- Improves error handling by conditionally using mocks in development mode.
- Updates Firebase authentication methods to utilize the lazy initialization.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/firebase/config.ts | Refactors Firebase initialization with lazy-loading; adds mocks and improved error logs. |
| lib/firebase/auth.ts | Modifies auth functions to use the new getter functions and initialization checks. |
| } else if (process.env.NODE_ENV === 'development') { | ||
| console.warn( | ||
| 'Firebase configuration is incomplete. Running in development mode with mock services.\n' + | ||
| 'To use real Firebase services, ensure all required environment variables are set in your .env.local file.' | ||
| ); | ||
| } |
Copilot
AI
May 25, 2025
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.
The 'else if' block after the try-catch appears to be unreachable or misplaced, which may result in inconsistent behavior in development mode. Consider revising the control flow to ensure that mocks and warnings are applied appropriately when configuration is incomplete.
| } else if (process.env.NODE_ENV === 'development') { | |
| console.warn( | |
| 'Firebase configuration is incomplete. Running in development mode with mock services.\n' + | |
| 'To use real Firebase services, ensure all required environment variables are set in your .env.local file.' | |
| ); | |
| } | |
| // Removed unreachable else if block. |
Fixes #7