TanStack / TanStack/router

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

Open
#3,907 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
15.1k
Forks
1.9k
Avg merge
1d 20h
Merged PRs (30d)
143

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with history/src/index.ts and the linked StackBlitz reproduction. Reproduce navigating to About and then using the browser back button, then trace how __TSR_index becomes NaN and how the notification action is selected. Done means back navigation emits a valid BACK action instead of GO with index NaN.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.