TanStack / TanStack/router

Redirect with deferred async event handler throws

Open
#2,844 0 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?

Start

Describe the bug

I have interesting problem with subscribing to events of router. Dev server crashes with error.

I'm trying to log events for analytical purposes (calling async fetch) on each page change (or page enter, before load or whatever, I dont care.).

For that Im using router.subscribe() API. But do not want to block rendering. So Im awaitting serverFunction, but server function itself does not await the fetch.

It works fine. but until I want to redirect. In such case my devserver throws and crashes.

See attached reproduction min example.

Your Example Website or App

https://github.com/ondrejvelisek/start-basic/tree/redirect

Steps to Reproduce the Bug or Issue
  1. https://github.com/ondrejvelisek/start-basic/tree/redirect
  2. pnpm install
  3. pnpm dev
  4. visit http://localhost:3000/redirect
  5. See dev server log, it thros error and dev server crashes
Expected behavior

It starts fetching, redirects and without blocking of rendering page it finishes fetch.

Screenshots or Videos

Image

Platform
  • OS: macOS
  • Browser: Chrome
  • Version: -
Additional context

I believe this works in TanStart "^1.73.1" but fails on "^1.82.6"

Fails on both Node and Bun.

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 the linked start-basic repository on its redirect branch, install with pnpm install, and run pnpm dev. Reproduce the crash by visiting /redirect, then compare the behavior across the reported TanStack Router versions and Node/Bun. Done means the deferred fetch can finish during a redirect without crashing the dev server.

Written by the indexing model from the issue text.

Assessment

Tech stack
bun, nodejs, typescript
Domain
full-stack
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.