Error states have a reset mechanism
Why it matters
Error state variables that are set on failure but never cleared produce a user-hostile artifact: a stale error banner that survives successful navigations, retries, and even cross-session logins on shared devices. Users who have already resolved the issue still see the old message, which undermines trust in the UI's accuracy and can leak information about a previous session's activity on a shared browser. Clearing error state before retries also prevents the double-state flash where old and new errors render simultaneously.
Severity rationale
Low because the bug is cosmetic and self-limiting, but it visibly erodes trust every time it appears.
Remediation
Reset every error state variable before the action that might produce a new one, and expose a dismiss mechanism on persistent banners. For global stores, add a clearError action and call it on route changes. Audit files under src/hooks/ and src/stores/ for setError calls without matching resets.
async function handleRetry() {
setError(null)
setLoading(true)
try { await fetchData() }
catch (err) { setError('Still failing.') }
finally { setLoading(false) }
}
For Zustand or Redux stores add clearError: () => set({ error: null }) and invoke it on navigation.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Error Handling Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
Taxons
History
- 2026-04-18·v1.0.0·Initial import from saas-error-handling·automated