Redirect with deferred async event handler throws
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
- https://github.com/ondrejvelisek/start-basic/tree/redirect
- pnpm install
- pnpm dev
- visit http://localhost:3000/redirect
- 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
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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