Code Monkey home page Code Monkey logo

Comments (9)

OrJDev avatar OrJDev commented on June 15, 2024 2

https://stackblitz.com/github/ardeora/solid-start-query-bug-repo

Could I get an isolated example with solid query that does double refetch? In this example above you can see that the request doesnt fire on client unless you switch tabs

https://github.com/OrJDev/solid-query-bug

here is a video of it actually broken.

2024-03-16.12-35-53.mp4

so in the video you can see that it calls the function on both client & server, causing it to render the wrong number, even tho i just opened the page and i disabled refetchOnWindowFocus.

from create-jd-app.

OrJDev avatar OrJDev commented on June 15, 2024 1

The trpc resolver is getting double-fetched, once on the server during SSR and once on client hydration.

Steps to reproduce:

  • update src/server/trpc/router/example.ts to:
  hello: procedure.input(z.object({ name: z.string() })).query(({ input }) => {

    const num = Math.random();

    console.log("hi", num);

    return `Hello ${input.name} ${num}`;

  }),
  • run the app

  • observe the SSR random number being displayed on page load and getting changed after a split-second.

Might be a tanstack query problem (their start example works properly, but is a couple start versions behind and updating it yields errors, so I gave up)

I think its under tanstack query because i remember facing this issue on trpc so i went back and checked what happens if i just run a query regardless of trpc, it still ran it twice. How about crate a new app and instead of using trpc just use createQuery and see if its being ran twice. If so an issue should be opened under tanstack query

from create-jd-app.

OrJDev avatar OrJDev commented on June 15, 2024

The trpc resolver is getting double-fetched, once on the server during SSR and once on client hydration.

Steps to reproduce:

  • update src/server/trpc/router/example.ts to:
  hello: procedure.input(z.object({ name: z.string() })).query(({ input }) => {

    const num = Math.random();

    console.log("hi", num);

    return `Hello ${input.name} ${num}`;

  }),
  • run the app

  • observe the SSR random number being displayed on page load and getting changed after a split-second.

Might be a tanstack query problem (their start example works properly, but is a couple start versions behind and updating it yields errors, so I gave up)

I think its under tanstack query because i remember facing this issue on trpc so i went back and checked what happens if i just run a query regardless of trpc, it still ran it twice. How about crate a new app and instead of using trpc just use createQuery and see if its being ran twice. If so an issue should be opened under tanstack query

So basically at the index page instead of calling .myRouter.query.createQuery()

Change it to

createQuery(() => ({ queryKey, queryFn))

Directly from solid query.

from create-jd-app.

OrJDev avatar OrJDev commented on June 15, 2024

yep so from what i tested even with a simple query like:

 const hello = createQuery(() => ({
    queryKey: ["test"],
    queryFn: async () => {
      console.log("called");
      const arn = Math.floor(Math.random() * 100);
      console.log({ arn });
      return `Hello ${arn}`;
    },
    refetchOnWindowFocus: false,
  }));

it is being fetched twice, once on client and once on server (first reload is ssr and second on client is because this function isn't server function). it should have rendered on the page 6 but it rendered 31 because it made another call on the client.

Screenshot 2024-03-13 at 12 31 05 Screenshot 2024-03-13 at 12 31 27

from create-jd-app.

OrJDev avatar OrJDev commented on June 15, 2024

cc @ardeora

 "dependencies": {
    "@solidjs/router": "^0.13.0",
    "@solidjs/start": "^0.7.4",
    "solid-js": "^1.8.15",
    "vinxi": "^0.3.10",
    "@solidjs/meta": "^0.29.3",
    "@solid-mediakit/trpc": "^3.0.0",
    "@tanstack/solid-query": "^5.27.5",
    "@trpc/client": "^10.45.1",
    "@trpc/server": "^10.45.1",
    "zod": "^3.22.4"
  },

from create-jd-app.

OrJDev avatar OrJDev commented on June 15, 2024

so basically the main issue here is not the hydration is that solid query makes 2 requests instead of 1 for some reason.

from create-jd-app.

ardeora avatar ardeora commented on June 15, 2024

https://stackblitz.com/github/ardeora/solid-start-query-bug-repo

Could I get an isolated example with solid query that does double refetch? In this example above you can see that the request doesnt fire on client unless you switch tabs

from create-jd-app.

ardeora avatar ardeora commented on June 15, 2024

Should be fixed in v5.28.5+ https://stackblitz.com/edit/github-fg2nmx?file=src%2Froutes%2Findex.tsx

from create-jd-app.

OrJDev avatar OrJDev commented on June 15, 2024

@shiro according to Aryan this is fixed

c890f64

please try and re-open this issue if you still face this bug.

from create-jd-app.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.