Skip to content

Scroll restoration can throw error when quota is exceeded #6241

@Xhale1

Description

@Xhale1

Which project does this relate to?

Router

Describe the bug

In the rare case that sessionStorage is full (10 MB in modern Chrome), using scrollRestoration: true can cause a crash on navigation.

Failed to execute 'setItem' on 'Storage': Setting the value of 'tsr-scroll-restoration-v1_3' exceeded the quota.

Your Example Website or App

https://stackblitz.com/edit/github-wnddb8nk?file=src%2Froutes%2Findex.tsx

Steps to Reproduce the Bug or Issue

  1. Go to the linked stackblitz
  2. Click the "Fill session storage" button
  3. Click between Home and About a few times to trigger navigations
  4. Observe the error

Expected behavior

I expect Tanstack Router to catch session storage errors and not crash the app. I think adding a try/catch to this bit of code would fix the issue

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.144.0
  • OS: macOS Tahoe
  • Browser: Chrome
  • Browser Version: 143.0.7499.170
  • Bundler: Vite
  • Bundler Version: 7.3.0

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions