Skip to content

Tanstack Start: Cannot route to agents #789

@imaai

Description

@imaai

There is this wierd bug occuring when you try to route the request to agents in tanstack start.

A header value for "X-Miniflare-Durable-Object-Cf-Blob" contains non-ASCII characters 
[...]. 
As a quirk to support Unicode, we are encoding values as UTF-8 in the header, but in a browser this would likely result in a TypeError exception. 
Consider encoding this string in ASCII for compatibility with browser implementations of the Fetch specification.

Context

// src/server.ts
import handler from "@tanstack/react-start/server-entry";
import { routeAgentRequest } from "agents";
  
export default {
    fetch: async (request: Request, env: Env, ctx: ExecutionContext) => {
        const response = await routeAgentRequest(request, env)
        if (!response) {
            return handler.fetch(request)
        }
        return response
    },
}
{
  "$schema": "node_modules/wrangler/config-schema.json",
  "name": "tanstack",
  "compatibility_date": "2025-09-02",
  "compatibility_flags": [
    "nodejs_compat"
  ],
  "main": "./src/server.ts",
  "durable_objects": {
    "bindings": [
      {
        "name": "Counter",
        "class_name": "Counter",
        "script_name": "src/agents/counter.ts"
      }
    ]
  }
}
const config = defineConfig({
  plugins: [
    cloudflare({ viteEnvironment: { name: 'ssr' } }),
    devtools(),
    // this is the plugin that enables path aliases
    viteTsConfigPaths({
      projects: ['./tsconfig.json'],
    }),
    tailwindcss(),
    tanstackStart(),
    viteReact(),
  ],
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions