Skip to content

__TSR_index is NaN, resulting in invalid history notifications (subscriber) #3907

Description

@wolkyura

Which project does this relate to?

Router

Describe the bug

I tried subscribing to router history changes to track back/forward navigation, but it's not working for me. When using the browser’s back/forward buttons, I get this action - { type: 'GO', index: NaN }.

I looked into history/src/index.ts and found that the history index is stored in __TSR_index, and in my case, it's NaN (see screenshot).

Your Example Website or App

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

Steps to Reproduce the Bug or Issue

  1. Navigate to About page
  2. Navigate back using browser back button

Expected behavior

I'd expect BACK action type being sent when using browser back button

Screenshots or Videos

Image

Platform

  • macOS
  • Chrome
  • Version: 134.0.6998.166

Additional context

No response

Activity

  1. schiller-manuel commented on Apr 1, 2025

    @schiller-manuel
    Collaborator
  2. LadyBluenotes commented on Jul 12, 2026

    @LadyBluenotes
    Member

    Thanks for the report. I can still reproduce this on current main.

    createBrowserHistory treats an existing key/__TSR_key as initialized state even when __TSR_index is missing. The next navigation then derives an index from undefined, which becomes NaN, and the following popstate is reported as GO.

    This needs a small normalization step for partial existing history state, plus a browser-history regression test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions