Skip to content

Bug: JSON.parse on localStorage user data without try-catch crashes the app #220

Description

@Siddh2024

Summary

In Client/src/App.jsx, JSON.parse(localStorage.getItem("user") || "{}") has no try-catch. Corrupted localStorage data crashes the entire React app on every route.

Details

  • File: Client/src/App.jsx
  • No error handling around localStorage deserialization
  • Corrupted data (e.g., from a previous app version) throws an uncaught exception
  • Also affects: token stored in localStorage instead of httpOnly cookies

Impact

Any localStorage corruption causes a complete app crash with no recovery. Users may need to manually clear site data to fix it.

Suggested Fix

Wrap in try-catch, default to null on failure, and clear corrupted entries automatically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions