Skip to content

Fix error-state handling, token refresh stale return, and modules null crash - #668

Merged
DeFiVC merged 4 commits into
ChainLearnOfficial:mainfrom
oomokaro1:fix/error-state-token-refresh-null-safety-555-558
Oct 23, 2026
Merged

DeFiVC merged 4 commits into
ChainLearnOfficial:mainfrom
oomokaro1:fix/error-state-token-refresh-null-safety-555-558

Conversation

@oomokaro1

Copy link
Copy Markdown
Contributor

Closes #555 , Closes #556, Closes #557, Closes #558

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Summary

Four small error-handling and null-safety bugs across the rewards, auth, and courses layers. fetchAll and fetchEnrollments swallowed fetch failures with console.error so the UI never showed an error; executeRefresh returned a stale JWT on refresh failure causing silent 401 retry loops; and getCourseModules crashed with Cannot read properties of undefined (reading 'sort') when the API omitted the modules field. 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 error state and cleared on success.

Closes #556 — executeRefresh now returns null on refresh failure instead of the stale token, so callers can disconnect rather than retry with a dead token.

Closes #557 — getCourseModules defaults course.modules to [] before sorting, so missing modules return an empty array instead of crashing.

Closes #558 — enrollment fetch errors are surfaced via the error state and cleared on a successful fetch.

Closes #555, Closes #556, Closes #557, Closes #558

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.
@netlify

netlify Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

❌ Deploy Preview for chainlearn failed.

Name Link
🔨 Latest commit 9d04f13
🔍 Latest deploy log https://app.netlify.com/projects/chainlearn/deploys/6adacf607e9efbccc2fd915a

@DeFiVC
DeFiVC merged commit a7d9e91 into ChainLearnOfficial:main Oct 23, 2026
1 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants