Skip to content

solid-query breaks in Astro SSR #11627

Description

@lachlancollins

Describe the bug

When trying to test out the solid-query Astro example, I noticed the server crashed on initial page load with the following error:

file:///home/.../query/node_modules/.pnpm/solid-js@1.9.12/node_modules/solid-js/dist/server.js:540
    const resolved = options.ssrLoadFrom !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
                                                                                               ^

TypeError: Cannot use 'in' operator to search for 'data' in undefined
    at prepareResource (file:///home/.../query/node_modules/.pnpm/solid-js@1.9.12/node_modules/solid-js/dist/server.js:540:96)
    at loading (file:///home/.../query/node_modules/.pnpm/solid-js@1.9.12/node_modules/solid-js/dist/server.js:555:5)
    at read.get (file:///home/.../query/node_modules/.pnpm/solid-js@1.9.12/node_modules/solid-js/dist/server.js:569:16)
    at Array.eval (/home/.../query/packages/solid-query/build/dev.js:280:55)
    at cleanNode (file:///home/.../query/node_modules/.pnpm/solid-js@1.9.12/node_modules/solid-js/dist/server.js:132:68)
    at cleanNode (file:///home/.../query/node_modules/.pnpm/solid-js@1.9.12/node_modules/solid-js/dist/server.js:128:49)
    ... collapsed 7 duplicate lines matching above 1 lines 7 times...
    at Timeout._onTimeout (file:///home/.../query/node_modules/.pnpm/solid-js@1.9.12/node_modules/solid-js/dist/server.js:54:52)
    at listOnTimeout (node:internal/timers:605:17)
    at process.processTimers (node:internal/timers:541:7)

After some digging around, the issue seems to be related to createResource, and specifically the prepareResource function. The resource.loading property calls this prepareResource() function, while some other properties do not. I will share a PR which seems to solve this issue shortly.

Your minimal, reproducible example

https://tanstack.com/query/latest/docs/framework/solid/examples/astro

Steps to reproduce

  1. Open the example in StackBlitz or Codesandbox
  2. See the console error

Expected behavior

Should successfully load the query on the server.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: Linux
  • Browser: Firefox
  • Version: solid-query 5.103.2

Tanstack Query adapter

solid-query

TanStack Query version

v5.103.2

TypeScript version

No response

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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