Skip to content

Latest commit

 

History

History
207 lines (164 loc) · 5.36 KB

ERROR_FIXES.md

File metadata and controls

207 lines (164 loc) · 5.36 KB

GPRM Error Fixes Documentation

Overview

This document outlines the runtime errors encountered in the GitHub Profile ReadMe Maker (GPRM) application and provides detailed fixes to prevent crashes and improve user experience.

Issues Identified

1. Broadcast API 404/503 Errors

Error: GET https://itsvg.in/api/broadcast 404 (Not Found)

Root Cause:

  • The itsvg.in API deployment is paused (Vercel status: DEPLOYMENT_PAUSED)
  • Axios throws uncaught promise rejection

Impact:

  • Console errors
  • Potential app instability

Fix:

// In components/broadcast/Broadcast.js
useEffect(() => {
  axios.get("https://itsvg.in/api/broadcast")
    .then((res) => {
      if (res.data.title) {
        setTitle(res.data.title);
        setLink(res.data.link);
        setIsVisible(true);
        setTimeout(() => {
          setIsVisible(false);
        }, 15000);
      }
    })
    .catch((error) => {
      console.warn("Broadcast API unavailable:", error.message);
      // Silently fail - no crash
    });
}, []);

2. Axios Unhandled Promise Rejections

Error: Uncaught (in promise) AxiosError {message: 'Request failed with status code 404'}

Root Cause:

  • Network requests failing without proper error handling

Impact:

  • Uncaught promise rejections crash the app

Fix: Add .catch() blocks to all Axios requests as shown in Issue #1.

3. MobX Strict Mode Violations

Error: [MobX] Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed. Tried to modify: ObservableObject@2.data.stats.theme

Root Cause:

  • MobX strict mode enabled (default in MobX 6)
  • Direct mutation of observable properties without action wrappers

Impact:

  • Console warnings/errors
  • Potential state management issues

Fix:

// In components/mobx/gprmStore.js
import { action, observable } from 'mobx';

export function createGPRMStore() {
  return observable({
    data: {
      // ... existing data structure
    },
    editData: action(function(id, value) {
      this.data[id] = value;
    }),
    updateStats: action(function(updates) {
      Object.assign(this.data.stats, updates);
    }),
  });
}

// In components/slides/GitHubCards.js
useEffect(() => {
  gprmStore.updateStats({
    theme,
    border,
    lifetime: includeAll,
    prv: includePrivate,
  });
}, [theme, border, includeAll, includePrivate]);

4. External API 503 Service Unavailable

Error: GET https://github-readme-stats.vercel.app/api/top-langs/... 503 (Service Unavailable)

Root Cause:

  • github-readme-stats.vercel.app service outages/down time
  • External dependency failures

Impact:

  • Broken images in UI
  • Console errors

Fix:

// In components/slides/GitHubCards.js - Add onError handlers to img tags
<img
  src={`https://github-readme-stats.vercel.app/api?username=${gprmStore.data.username}...`}
  alt="GitHub Stats"
  onError={(e) => {
    e.target.style.display = 'none';
    console.warn('GitHub stats image failed to load');
  }}
/>

5. Form Submission Canceled Warning

Error: Form submission canceled because the form is not connected

Root Cause:

  • Form elements without proper event handlers or connections

Impact:

  • Browser warnings
  • Potential UX issues

Fix:

  • Inspect form elements in components
  • Add onSubmit={(e) => e.preventDefault()} if forms are not meant to submit
  • Ensure proper form connections

GitHub Issue Template

Title

Runtime Errors: API Failures & MobX Strict Mode Violations Causing App Instability

Body

## 🐛 Bug Report

### Description
The app encounters multiple runtime errors that degrade user experience:

1. **Broadcast API 404/503** - External API failures
2. **Axios Unhandled Errors** - Network failures throw uncaught promises
3. **MobX Strict Mode Violations** - Direct observable mutations
4. **External API 503s** - github-readme-stats service outages
5. **Form Submission Warnings** - Disconnected forms

### Steps to Reproduce
1. Run `npm run dev`
2. Open browser console
3. Navigate through app (especially GitHub stats)
4. Observe errors when external APIs are down

### Expected Behavior
- Graceful handling of external API failures
- No console errors from network issues
- Compliant MobX state updates

### Proposed Solution
Implement comprehensive error handling as documented in ERROR_FIXES.md

### Environment
- Node.js: [version]
- npm: [version]
- Browser: [browser]
- OS: [OS]

Implementation Priority

  1. High Priority:

    • MobX strict mode fixes (prevents state corruption)
    • Axios error handling (prevents crashes)
  2. Medium Priority:

    • Image onError handlers (improves UX)
    • Form submission fixes (cleans up warnings)
  3. Low Priority:

    • Enhanced logging/error reporting

Testing

After implementing fixes:

  1. Run npm run build to ensure no syntax errors
  2. Test with network disconnected to simulate API failures
  3. Verify console is clean during normal operation
  4. Test GitHub stats section with invalid usernames

Dependencies

  • MobX 6+ (for observable/action)
  • Axios (for HTTP requests)
  • React (for error boundaries if needed)

Notes

  • External APIs (itsvg.in, github-readme-stats) are third-party services
  • App should be resilient to their failures
  • Consider implementing retry logic for critical APIs
  • Add loading states for better UX during API calls