Skip to content

[solid-start] InfiniteQuery causes "Cannot serialize function" with renderStream #6312

@iksaku

Description

@iksaku

Describe the bug

I'm developing a project using SolidStart. For configuration, I've enabled SSR + Stream Rendering (renderStream()).
For this project, I'm trying to use createInfiniteQuery() to load some paginated data, however, upon starting the render stream, I get an error referring to serialization of a function.

Click here to show full error log
An unhandled error occured: Error: Cannot serialize function without reference ID.
    at Y.parse (/home/projects/vitejs-vite-vmmjwb/node_modules/.pnpm/seroval@0.12.3/node_modules/seroval/dist/esm/production/index.mjs:32:38620)
    at Y.parseProperties (/home/projects/vitejs-vite-vmmjwb/node_modules/.pnpm/seroval@0.12.3/node_modules/seroval/dist/esm/production/index.mjs:32:33262)
    at Y.parsePlainObject (/home/projects/vitejs-vite-vmmjwb/node_modules/.pnpm/seroval@0.12.3/node_modules/seroval/dist/esm/production/index.mjs:32:33546)
    at Y.parseObject (/home/projects/vitejs-vite-vmmjwb/node_modules/.pnpm/seroval@0.12.3/node_modules/seroval/dist/esm/production/index.mjs:32:43407)
    at Y.parse (/home/projects/vitejs-vite-vmmjwb/node_modules/.pnpm/seroval@0.12.3/node_modules/seroval/dist/esm/production/index.mjs:32:38464)
    at Y.parseWithError (/home/projects/vitejs-vite-vmmjwb/node_modules/.pnpm/seroval@0.12.3/node_modules/seroval/dist/esm/production/index.mjs:32:45480)
    at eval (/home/projects/vitejs-vite-vmmjwb/node_modules/.pnpm/seroval@0.12.3/node_modules/seroval/dist/esm/production/index.mjs:32:42649)

It seems like the cause is pretty obscure and I've double checked that I'm not doing some black magic myself to be hitting this wall. Also, I've run a mock infinite query using createQuery() and it doesn't show any serialization error, making me wonder what could be different in the internals of both functions for one to be having problems and the other not.

When this error shows (every time I load the route using createInfiniteQuery()), it appears as if the response never stops streaming (browser never stops "loading") when running the project outside of sandbox, but I expect this is part of the issue and the combination of the project settings.

Your minimal, reproducible example

https://stackblitz.com/edit/vitejs-vite-vmmjwb?file=src%2Froutes%2Findex.jsx

Steps to reproduce

  1. Open reproduction example using Chrome/Chromium if possible (Fails to load on Firefox for some reason)
  2. Wait for SolidStart to run in the console
  3. When the application loads, the preview window will display the Hello! message, and at the same time, the serialize error will show in console.

Expected behavior

  1. Serialization should work without issues as data is truly plain and we're not doing crazy stuff with it.
  2. I expect that once this serialization issue is resolved, the render stream can end properly.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: macOS Sonoma
  • Browser:
    • Chrome: 117
    • Firefox (Developer Edition): 119

Tanstack Query adapter

solid-query

TanStack Query version

v5.4.3

TypeScript version

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions