nicoalbanese / kirimase

Build full-stack Next.js apps, incredibly fast
https://kirimase.dev
MIT License
2.39k stars 107 forks source link

Stale data using experimental_nextCacheLink #89

Closed Ipicon closed 7 months ago

Ipicon commented 7 months ago

After a whole day of debugging why am I getting stale data even though I revalidate everything, I saw this discussion: https://discord-questions.trpc.io/m/1150707553068650579

the problem with this, is that the api variable doesn't sit under the context (because it's on the server), and when calling revalidate it doesn't effect all server rendered components.

now managing the cache on the api var is quite a hustle, maybe we should approach this like T3 does? create a custom RSC link that lets us invoke procedures without using http at all.

nicoalbanese commented 7 months ago

Hey! Yes I’ve been running into issues too with context here. Planning on updating implementation to t3s’ later this week. Hopefully will resolve it 🤞

On Mon, 27 Nov 2023 at 22:57, Max Shulov @.***> wrote:

After a whole day of debugging why am I getting stale data even though I revalidate everything, I saw this discussion: https://discord-questions.trpc.io/m/1150707553068650579

the problem with this, is that the api variable doesn't sit under the context (because it's on the server), and when calling revalidate it doesn't effect all server rendered components.

now managing the cache on the api var is quite a hustle, maybe we should approach this like T3 does? the create a custom RSC link that lets them innoke procedures without using http at all.

— Reply to this email directly, view it on GitHub https://github.com/nicoalbanese/kirimase/issues/89, or unsubscribe https://github.com/notifications/unsubscribe-auth/AL2QPCVCZRYNGNOXCDSO34TYGULFHAVCNFSM6AAAAAA74YNVIGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGAYTGMRXGE2DAMA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Ipicon commented 7 months ago

@nicoalbanese thanks for the fast reply. 😁 I don't mind helping with a PR if you want

nicoalbanese commented 7 months ago

No stress - I had actually already started working on it a few days ago so figured fastest to just finish it off. Thanks!

Ipicon commented 7 months ago

@nicoalbanese another nice thing we can do is injecting the db prop inside the context, which can fix help with reconnection issues in some environments

nicoalbanese commented 7 months ago

@Ipicon check this out: https://github.com/nicoalbanese/kirimase/blob/c80277c24c072ba8f18cdfa6766a6e4d95d55002/src/commands/add/misc/trpc/generators.ts#L321

This was the same approach t3 had, putting it directly into the context. Is that what you mean?

Ipicon commented 7 months ago

@nicoalbanese exactly! I already went over this commit and saw you did it.😁