Describe the bug
The CookieConsent component accesses localStorage.getItem and localStorage.setItem directly without a try-catch block. In highly restrictive browser environments (like strict incognito modes, or when third-party cookies/data are completely disabled by the user), accessing localStorage throws a fatal DOMException. Because there is no local React Error Boundary, this unhandled exception crashes the entire application.
To Reproduce
Steps to reproduce the behavior:
- Open Google Chrome.
- Go to Settings > Privacy and Security > Cookies and other site data.
- Select "Block all cookies" (not recommended, but used for testing restrictive environments).
- Navigate to the DevPath application.
- See error: The screen is completely white (or shows the next.js error overlay in dev mode) due to an unhandled
DOMException thrown by the CookieConsent component.
Expected behavior
The application should degrade gracefully. If localStorage throws an error, the CookieConsent component should catch it and either assume the user has not consented, or hide the banner without crashing the rest of the application.
Screenshots
N/A
Desktop (please complete the following information):
- OS: All
- Browser: Chrome, Firefox (Strict Mode)
- Version: Latest
Smartphone (please complete the following information):
- Device: All
- OS: All
- Browser: All
Additional context
File affected: src/components/CookieConsent.jsx. Wrapping the storage accesses in a standard try-catch block will resolve the issue.
Describe the bug
The
CookieConsentcomponent accesseslocalStorage.getItemandlocalStorage.setItemdirectly without atry-catchblock. In highly restrictive browser environments (like strict incognito modes, or when third-party cookies/data are completely disabled by the user), accessinglocalStoragethrows a fatalDOMException. Because there is no local React Error Boundary, this unhandled exception crashes the entire application.To Reproduce
Steps to reproduce the behavior:
DOMExceptionthrown by theCookieConsentcomponent.Expected behavior
The application should degrade gracefully. If
localStoragethrows an error, theCookieConsentcomponent should catch it and either assume the user has not consented, or hide the banner without crashing the rest of the application.Screenshots
N/A
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
File affected:
src/components/CookieConsent.jsx. Wrapping the storage accesses in a standard try-catch block will resolve the issue.