TanStack / TanStack/router

ServerFunction does not serialize from client-side loader invocation

Open
#7,437 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

information needed
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'm seeing the most boring server function imaginable fail to de-serialize when called from a client-side loader.

Repro below

Complete minimal reproducer

https://github.com/arackaf/my-blog/tree/special/bug-repro

Steps to Reproduce the Bug

Clone
npm i
npm run dev
browse here: http://localhost:3000/blog/swift-codable-any
then click the back arrow at the top

Page should error out. But then refresh the page on that root url - it should load

What's crazy is that the serverFn in that root url returns static data. I can't imagine what's making it fail to serialize

.handler(async () => {
return [
{
markdownContent: "",
title: "Swift - Encoding and decoding Any",
date: "2022-07-12T10:00:00.000Z",
description: "How to encode and decode json with concrete types, which include dynamic pieces typed as Any",
slug: "swift-codable-any",
},
];

Expected behavior

Should work :)

Screenshots or Videos

n/a

Platform
  • Router / Start Version: [e.g. 1.121.0]
    "@tanstack/react-router": "^1.170.4",
    "@tanstack/react-start": "^1.168.6",
  • OS: [e.g. macOS, Windows, Linux]
    macOS
  • Browser: [e.g. Chrome, Safari, Firefox]
    Chrome
  • Browser Version: [e.g. 91.1]
    148
  • Bundler: [e.g. vite]
    Vite
  • Bundler Version: [e.g. 7.0.0]
    7.1.7
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 the linked minimal reproducer: run npm i, npm run dev, open /blog/swift-codable-any, and click the back arrow. Trace the client-side loader invocation and server-function serialization, comparing it with a direct refresh of the root URL. Done means the navigation loads the static server-function result without an error.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript, vite
Domain
backend-api-design, full-stack
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.