Bug encountered after upgrading to version 2.0.5 causing Desk tool crash on studio pages with preview imagery.

9 replies
Last updated: Oct 20, 2020
I just upgraded from 1.150.7 to 2.0.5, and I encountered a Desk tool crash whenever I try to go to a studio page that has any Preview imagery. Seems to occur on any page studio page that might show thumbnails or when I launch an image browser to view/select an image. Initially I thought it was because of using the
sanity-plugin-media
so I uninstalled that, but it’s pretty consistent crash error on any page with a preview. Is there something else I should do for an upgrade? I’ll include the stack trace on this thread.
Oct 20, 2020, 3:56 PM
The 'Desk' tool crashed

TypeError: type.to.find is not a function
    at RenderPreviewSnapshot (/static/js/app.bundle.js:164631:51)
    at <http://localhost:3333/static/js/app.bundle.js:89549:16>
    at ObserveForPreview (/static/js/app.bundle.js:163171:10)
    at renderWithHooks (/static/js/vendor.bundle.js:17546:18)
    at mountIndeterminateComponent (/static/js/vendor.bundle.js:20226:13)
    at beginWork (/static/js/vendor.bundle.js:21350:16)
    at HTMLUnknownElement.callCallback (/static/js/vendor.bundle.js:2909:14)
    at Object.invokeGuardedCallbackDev (/static/js/vendor.bundle.js:2958:16)
    at invokeGuardedCallback (/static/js/vendor.bundle.js:3013:31)
    at beginWork$1 (/static/js/vendor.bundle.js:25955:7)

Oct 20, 2020, 3:57 PM
And in case it might be the culprit, here is my schema for a document that shows this consistent crash. I’m not noting a preview or anything here so I’m relying on default system behavior for the thumbnails.

export default {
  name: 'screensaver',
  title: 'Screensaver',
  type: 'document',
  fields: [
    {
      name: 'title',
      title: 'Title',
      type: 'string'
    },
    {
      name: 'asset',
      title: 'Content',
      description: 'Please select a series of images or videos',
      type: 'array',
      of: [
        {
          type: 'image',
          title: 'Image',
          to: { type: 'image' }
        },
        {
          type: 'mux.video',
          title: 'Video',
          to: { type: 'mux.video' }
        }
      ]
    }
  ]
};
Oct 20, 2020, 4:01 PM
Hi User, thanks for reporting this one. I don’t think we’ve seen it before but it definitely looks like a bug. We’ll try to reproduce and get a fix in place 🙂
Oct 20, 2020, 4:10 PM
Hi User, thanks for reporting this one. I don’t think we’ve seen it before but it definitely looks like a bug. We’ll try to reproduce and get a fix in place 🙂
Oct 20, 2020, 4:10 PM
I think I know why this is happening and where the bug lives 👀 Will take a look tomorrow 🕵️‍♀️
Oct 20, 2020, 7:05 PM
Also it might be happening because your
to
in the schema are objects instead of arrays. Can you see if wrapping them in
[]
fixes the problem?
Oct 20, 2020, 7:18 PM
Btw, why do you have
to
here by the way? I believe
to
is used when you have a reference type 🤔
{
          type: 'image',
          title: 'Image',
          to: { type: 'image' }
        },
        
Oct 20, 2020, 7:20 PM
You are totally right
user H
. Removing the
to
block there resolved this. Seems we initially had these as reference types but switched over and never removed that line. We never got an error on 1.150 so thought it was okay. Thank you!
Oct 20, 2020, 7:38 PM
Awesome! Happy to hear it’s working 🥳
Oct 20, 2020, 7:40 PM

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?