Go Behind the Experience to see how Tecovas brings the West to life with Sanity 🤠 July 18th

Issue with high API CDN requests in Sanity V3 and Remix, resolved by removing fetch request in healthcheck file.

13 replies
Last updated: Sep 19, 2022
Hey folks! Been playing around with Sanity V3, Remix and the Shopify Connect over the last couple of weeks and I’ve noticed we’re getting a huge amount of API CDN requests (hitting about 50k a day 😰 ) Is there any way to get more info out of the usage data to maybe see where this is coming from? Thanks 🙂
Sep 13, 2022, 7:54 AM
Should mention this is a proof of concept piece so it’s only me visiting the site etc.
Sep 13, 2022, 8:13 AM
Yes there is and yes there is! But I think I might know what the issue might be: syncing sanity to the cart (which means, that every-time something in the cart is happening, an api call is fired.If you send me your projectID and details in a DM I can also provide you with a more detailed account of your data usage.
And I will see if I can find the most recent version of a POC..
Sep 13, 2022, 1:12 PM
Amazing thank you! I’ll send it over now 🙂
Sep 13, 2022, 3:21 PM
The Sanity Shopify Connect app is set to sync products and collections manually, and the last sync was on the 9th September
Sep 14, 2022, 7:50 AM
I think the reason you’re seeing this kind of volume is def. some sort of error in your code (useEffect or some other hook)
Sep 14, 2022, 3:32 PM
since we know the culprit queries (DM) you should check where there are called and why so many times per day!What framework are you using?
Sep 14, 2022, 3:33 PM
Ahh cool thanks. Hmm interesting, we’re using Remix and the worst offender is a query in the root.tsx file so I’ll go and have a look at that and see what’s going on there
Sep 14, 2022, 3:51 PM
Okay so I need to double check this tomorrow morning (as it’s time I went home lol) but it looks as though my query is getting picked up in my healthcheck endpoint and fly.io is querying it every 10 seconds 🙃 whoops!
Sep 14, 2022, 4:09 PM
Sep 14, 2022, 4:11 PM
Yeah i need to go …. to the other room #remote💜life
Sep 14, 2022, 4:11 PM
Hey! Just to follow up on this with a more detailed answer in case anyone comes across this in the future (or I do it again 😂 )
In the Remix Indie Stack there is a
heathcheck route intended for services like fly.io to call at regular intervals, the default is every 10 seconds.
Inside that healthcheck there is a loader function containing a fetch request which fetches the homepage and returns an “OK” response if it connects okay.

If you have any queries to Sanity in the
function on that page (either in
in this case, then they will get called when the fetch runs.
I’ve resolved this by removing the fetch request to the homepage from the healthcheck file.
Sep 16, 2022, 3:11 PM
Appreciate the extra effort! And wonderful you found it as well 💪If you want, you can publish this in our
Exchange platform and make this also google-able and get your name under the solution 🙂
Sep 19, 2022, 7:21 AM
This made me giggle on monday morning …. so extra thanks 😉
Sep 19, 2022, 7:22 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?