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
thanks
user Y
, let me grab that for you
Aug 5, 2021, 6:37 PM
is this helpful?
Aug 5, 2021, 6:38 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&amp;tag=sanity.studio.preview.document-paths>
Aug 5, 2021, 6:39 PM
that’s the request it’s making
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
in the projection, that messes it up
Aug 5, 2021, 6:39 PM
how does the preview code look like?
Aug 5, 2021, 6:40 PM
interesting
Aug 5, 2021, 6:40 PM
so this is what the preview looks like:
Aug 5, 2021, 6:40 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
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
ah interesting
Aug 5, 2021, 6:51 PM
I was getting it even on just plain reference fields as well
Aug 5, 2021, 6:51 PM
(aka no preview)
Aug 5, 2021, 6:51 PM
I see i see
Aug 5, 2021, 6:51 PM
Which version of the studio is this?
Aug 5, 2021, 6:52 PM
but it’s been spotty, like sometimes the reference fields will load up their selection just fine
Aug 5, 2021, 6:52 PM
that’s what I got ^
Aug 5, 2021, 6:52 PM
tnx!
Aug 5, 2021, 6:53 PM
thank you!
Aug 5, 2021, 6:53 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
I just checked hull locally, no issues there it seems
Aug 5, 2021, 6:58 PM
it’s with a particular studio
Aug 5, 2021, 6:58 PM
4qwkswbv
is the project ID if that helps
Aug 5, 2021, 6:59 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
bingo
Aug 5, 2021, 8:12 PM
Amazing support! 🙇‍♂️
Aug 5, 2021, 9:01 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.

Was this answer helpful?

Categorized in