Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while trying to use TRPC serverside #14

Closed
krystiangryczon opened this issue Sep 7, 2023 · 5 comments
Closed

Error while trying to use TRPC serverside #14

krystiangryczon opened this issue Sep 7, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@krystiangryczon
Copy link

I'm trying to use serverside TRPC client, I think it should be used like so:

import { api } from "@/lib/trpc/api";

export default async function Home() {
  const data = await api.computers.getComputers.query();

but it's giving me the error of:

Error: cache: 'force-cache' used on fetch for https://localhost:3306/psdb.v1alpha1.Database/Execute with 'export const fetchCache = 'only-no-store'

I can't seem to find any solution for that, Am I using it wrong?

@nicoalbanese
Copy link
Owner

Hey Krystian - thanks for flagging. Are you using planetscale? I encountered this issue as well (only with planetscale) and haven't been able to find a solution. For the time being, I've been using the underlying query that runs on the server (so in this case getComputers()) in the server component and then sending that data down to a client component that uses trpc on the client side.

For the server side TRPC implementation, I'm leveraging an experimental feature from the TRPC team called server invocation. Hopefully as the Nextjs team solves the issues around caching, this will get resolved.

@nicoalbanese nicoalbanese added the bug Something isn't working label Sep 7, 2023
@krystiangryczon
Copy link
Author

yes, I'm using MySQL with Planetscale. I've also tried implementing the experimental features to get TRPC to work on the server with app dir before I learned about your project, but with little success.

Yea, noticed your PR changing from using api.computers.getComputers to getComputers right after I posted the issue hah, will use the same approach for now and hopefully we have the issue sorted in the near future!

Great work on the Kirimase, love it already

@nicoalbanese
Copy link
Owner

Ha yes indeed - stumped me for a while and then I just gave up. Hopefully resolved soon! and thank you, happy to hear 😊

@statusunknown418
Copy link

think for now the best would be to use plain db calls instead of trpc for RSCs until it's solved

@kddige
Copy link
Contributor

kddige commented Sep 12, 2023

I just encountered the same issue -, solution for me was to only invoke db calls using the planetscale driver on the edge.

Solution
page.tsx:

export const runtime = "edge"

Do we know why this could be? 🤔 Also, maybe not the forum to discuss this, but anyway. Ill leave it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants