Repository navigation
Fix error-state handling, token refresh stale return, and modules null crash - #668
Merged
DeFiVC merged 4 commits intoOct 23, 2026
Conversation
fetchAll swallowed balance/history fetch failures with console.error, leaving the UI stuck on empty data with no error indication. Set the existing error state in the catch block and clear it on success.
When token refresh failed and isTokenExpired returned false (e.g. JWT with no readable expiry), executeRefresh returned the stale token. Callers then retried with a dead token, creating a silent 401 loop. Return null so callers can disconnect instead.
course.modules.sort() threw when the API omitted the modules field, crashing the module list page. Default to an empty array so missing modules return [] instead of throwing.
fetchEnrollments swallowed failures with console.error, so users never knew their enrollment data failed to load. Set the error state in the catch block and clear it on a successful fetch.
❌ Deploy Preview for chainlearn failed.
|
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #555 , Closes #556, Closes #557, Closes #558
Type of Change
Summary
Four small error-handling and null-safety bugs across the rewards, auth, and courses layers.
fetchAllandfetchEnrollmentsswallowed fetch failures withconsole.errorso the UI never showed an error;executeRefreshreturned a stale JWT on refresh failure causing silent 401 retry loops; andgetCourseModulescrashed withCannot read properties of undefined (reading 'sort')when the API omitted themodulesfield. Each fix is a 1–4 line change at the failure site.Motivation / Context
Closes #555 — balance/history fetch errors are now exposed via the existing
errorstate and cleared on success.Closes #556 —
executeRefreshnow returnsnullon refresh failure instead of the stale token, so callers can disconnect rather than retry with a dead token.Closes #557 —
getCourseModulesdefaultscourse.modulesto[]before sorting, so missing modules return an empty array instead of crashing.Closes #558 — enrollment fetch errors are surfaced via the
errorstate and cleared on a successful fetch.Closes #555, Closes #556, Closes #557, Closes #558