Help me understand how this happened - Invalid cursor / broken cache #3134
Unanswered
freakspace
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
❌ Hydrogen Storefront Error
Message:
Invalid cursor for current pagination sort.
Context:
storefront.query
in Hydrogen7f6800ab-3058-430d-be9a-252d45d21674-1756350596
Debugging Tips:
CollectionDetails
query in GraphiQL.Stack Trace:
at loader (app/routes/($locale).collections.$collectionHandle.tsx:66)
at callRouteLoader (.vite/deps_ssr/@remix-run_server-runtime.js:3221)
at (.vite/deps_ssr/@remix-run_server-runtime.js:3321)
at actualHandler (.vite/deps_ssr/@remix-run_server-runtime.js:2056)
at (.vite/deps_ssr/@remix-run_server-runtime.js:2064)
at runHandler (.vite/deps_ssr/@remix-run_server-runtime.js:2075)
at callLoaderOrAction (.vite/deps_ssr/@remix-run_server-runtime.js:2123)
at resolve (.vite/deps_ssr/@remix-run_server-runtime.js:2021)
First of all, I really love Hydrogen, it's great.
tl;dr
I changed the cache on the collection query/loader. Everything seemed fine locally and in preview, but in production pagination broke with a “cursor doesn’t exist” error.
Rolling back to older deployments and testing locally showed the same error, even though pagination definitely worked in the past. Reverting my cache changes didn’t help either.
I found a Shopify forum post matching my error: removing the sortKey from the query fixed it, and suddenly all past deployments worked again.
My guess: the issue is related to cached queries, probably cached cursors.
Lengthy explanation
This week I experience some critical issue i still have yet to fully understand.
I did some changes to the cache configuration, specifically I changed the cache on the collection query and loader.
All seemed to work fine locally, and releasing it to preview also seemed to work fine.
I then deployed to production, and to my surprise, the collections didn't work.
Specifically when paginating, the page would break, because the cursor didn't exist. (I don't remember if i tested pagination locally or in preview, I simply didn't think of it).
I tested on a different device - same error.
As panic set, I rolled back to a past deployment from 2 weeks ago. To my surprise, that was also broken.
I then checked locally where no cache is set. Also broken.
Then i looked at a preview 1 month back. Also broken.
Then i looked at a preview from my very first commit. Also broken!
I know for sure pagination worked in the past. 100% certainty.
So some change in my recent deployment, literally broke all past deployments.
It has to be something about the cache?
But what I don't understand, isn't the cache completely separate in deployments?
I then reverted the cache changes back. That didn't work either!
I then found this issue: https://community.shopify.com/t/storefront-api-pagination-returns-error-when-sorting-by-created/346094
Which matched the specific error I had.
So what I did was to remove the sortKey from the query, and It worked again.
And all past deployments worked again.
Today I created a new branch ad added the sortKey back again, just to see what would happen, and it still works.
My own guess it has to be related to a cached query - i suppose the cursors are cached?
Beta Was this translation helpful? Give feedback.
All reactions