Skip to content

[BUG] Unhandled DOMException in CookieConsent.jsx (Application Crash) #673

@Niteshagarwal01

Description

@Niteshagarwal01

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:

  1. Open Google Chrome.
  2. Go to Settings > Privacy and Security > Cookies and other site data.
  3. Select "Block all cookies" (not recommended, but used for testing restrictive environments).
  4. Navigate to the DevPath application.
  5. 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.

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions