Bug in preview select optimization causing performance degradation in studio requests.
31 replies
Last updated: Aug 5, 2021
been hearing about performance degradation, curious what I’m supposed to do here?
Aug 5, 2021, 6:12 PM
Sorry about this. It seems like the studio sends requests that’s malformed. Would it be possible to see the payload of the request that returns 400?
Aug 5, 2021, 6:20 PM
We don’t see elevated error rates so makes me think that there might be some cross wiring somewhere
Aug 5, 2021, 6:22 PM
<https://4qwkswbv.api.sanity.io/v1/data/query/production?query=%5B*%5B_id%20in%20%5B%2277144dbd-a26c-45a2-a6ea-c59e7a93c69d%22%2C%22e130bb98-d5f7-4338-80ef-c339735ffdab%22%5D%5D%5B0...2%5D%7B_id%2C_rev%2C_type%2C%2Cslug%7D%5D%5B0...1%5D&tag=sanity.studio.preview.document-paths>
Aug 5, 2021, 6:39 PM
Yeah, for some reason there’s an empty space/double commas here:
{_id,_rev,_type,,slug}
Aug 5, 2021, 6:39 PM
preview: { select: { title: 'title', hasPage: 'page', pageType: 'page._type', pageSlug: 'page.slug.current' }, prepare({ title, hasPage, pageType, pageSlug }) { const isStatic = getStaticRoute(pageType) const isDynamic = getDynamicRoute(pageType) return { title: title, subtitle: hasPage ? isStatic !== false ? `/${isStatic}` : `/${isDynamic ? `${isDynamic}/` : ''}${pageSlug}` : null } } }
Aug 5, 2021, 6:40 PM
very similar to what is in hull: https://github.com/ndimatteo/HULL/blob/main/studio/schemas/objects/nav-page.js#L24-L42
Aug 5, 2021, 6:42 PM
Gotcha, we’re looking into it. But this is most probably a bug in the preview code, and at least not degraded API performance
Aug 5, 2021, 6:49 PM
but it’s been spotty, like sometimes the reference fields will load up their selection just fine
Aug 5, 2021, 6:52 PM
can this be reproduced in HULL, or do you only experience this with this particular studio – if you can say
Aug 5, 2021, 6:54 PM
aight - the team is looking into it. Maybe if you could zip the studio folder and post it to me on DM that would be helpful
Aug 5, 2021, 7:02 PM
Summary: We have poked the code and found a bug in the preview select optimization where selecting a reference field can return
undefined. the hotfix is to do e.g.
page._id. We’ll also push a fix for it.
Aug 5, 2021, 7:41 PM
I
bingo
Aug 5, 2021, 8:12 PM
Sanity– build remarkable experiences at scale
The Sanity Composable Content Cloud is the headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.