Description
Currently, fetchUserInfo treats the external LeetCode API as a mandatory dependency. If the live API returns a non-200 status code (e.g., 500 Server Error or 429 Too Many Requests), the livePromise throws an error. Because this error propagates, it prevents the entire function from completing, meaning the UI fails to display even the cached historical data and badges stored in your repository.
Proposed Solution
Make the Live API fetch "graceful" (optional). If fetchWithTimeout for the live API fails, the function should catch the error locally, log it, and allow the function to proceed by returning the already-fetched historical data with ranking and contest set to null.
Implementation Details
- Update the
livePromise logic to use a .catch() block that handles errors locally.
- Prevent the error from throwing/propagating to the main
fetchUserInfo flow.
- Ensure the function returns a consistent object structure even when the live data is unavailable.
Benefits
- Improved UX: Students will still be able to view their profile, history, and badges even if the external LeetCode API is temporarily experiencing downtime.
- Resilience: Decouples the platform's core dashboard functionality from the health of an external, third-party service.
Reference: This addresses the single-point-of-failure in data fetching within fetchUserInfo.js.
Description
Currently,
fetchUserInfotreats the external LeetCode API as a mandatory dependency. If the live API returns a non-200 status code (e.g., 500 Server Error or 429 Too Many Requests), thelivePromisethrows an error. Because this error propagates, it prevents the entire function from completing, meaning the UI fails to display even the cached historical data and badges stored in your repository.Proposed Solution
Make the Live API fetch "graceful" (optional). If
fetchWithTimeoutfor the live API fails, the function should catch the error locally, log it, and allow the function to proceed by returning the already-fetched historical data withrankingandcontestset tonull.Implementation Details
livePromiselogic to use a.catch()block that handles errors locally.fetchUserInfoflow.Benefits
Reference: This addresses the single-point-of-failure in data fetching within
fetchUserInfo.js.