Skip to content

refactor: guard console.error calls behind DEV environment check - #232

Merged
khanirfan18 merged 2 commits into
khanirfan18:mainfrom
bh462007:fix/guard-console-error-production
Jul 16, 2026
Merged

refactor: guard console.error calls behind DEV environment check#232
khanirfan18 merged 2 commits into
khanirfan18:mainfrom
bh462007:fix/guard-console-error-production

Conversation

@bh462007

Copy link
Copy Markdown
Contributor

Related Issue

Closes #212


Summary

This PR updates the context files to ensure console.error() is only executed during development. The logs are now wrapped with import.meta.env.DEV, preventing unnecessary error output in production while keeping the same debugging experience during local development.


Changes

src/context/AppContext.jsx

  • Wrapped the console.error call in the exchange rates fetch .catch() block.
  • Wrapped the console.error call in the Supabase loadData catch block.

src/context/AuthContext.jsx

  • Wrapped the console.error call in the loadSession catch block.
  • Wrapped the console.error call in the signOut error handling block.
  • Wrapped the console.error call in the signOut catch block.

What Stayed the Same

  • User-facing error handling remains unchanged (setAuthError, setSession(null), return false, etc.).
  • The existing catch blocks and control flow are untouched.
  • This change only affects when error logs are printed.

Implementation

Before:

console.error(error);

After:

if (import.meta.env.DEV) {
  console.error(error);
}

import.meta.env.DEV is Vite's built-in environment flag. It evaluates to true while running the development server and false in production builds, so console error logs are automatically omitted from production.


Type of Change

  • Refactor (no functional changes)

Copilot AI review requested due to automatic review settings June 27, 2026 15:34
@netlify

netlify Bot commented Jun 27, 2026

Copy link
Copy Markdown

👷 Deploy request for finnboard0 pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 72b87c0

@netlify

netlify Bot commented Jun 27, 2026

Copy link
Copy Markdown

Deploy Preview for finnboard ready!

Name Link
🔨 Latest commit 72b87c0
🔍 Latest deploy log https://app.netlify.com/projects/finnboard/deploys/6a50ced3c690ee00086a8934
😎 Deploy Preview https://deploy-preview-232--finnboard.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@khanirfan18

Copy link
Copy Markdown
Owner

@bh462007 fix conflicts

@khanirfan18
khanirfan18 merged commit 74bb998 into khanirfan18:main Jul 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor: Guard or remove console.error calls in production-facing context files

3 participants