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.
AI Update

I understand you're experiencing crashes in Sanity Studio when viewing pages with image previews after upgrading from v1.150.7 to v2.0.5. The "Cannot read property palette of undefined" error is a specific issue that occurred in Studio v2 related to image metadata processing.

Immediate fixes to try:

1. Clear cached build artifacts and reinstall

The most common cause of desk tool crashes after upgrading is stale cached data:

rm -rf node_modules .sanity
npm install
sanity start

The .sanity folder contains webpack build cache that can conflict with the new version, especially for image asset handling.

2. Update all @sanity packages together

Version mismatches between core packages often cause the "palette" error. Ensure all your @sanity/* packages are at compatible v2 versions:

npm install @sanity/base@2.0.5 @sanity/desk-tool@2.0.5 @sanity/default-layout@2.0.5 @sanity/default-login@2.0.5

Check your package.json - all @sanity/* packages should be at the same 2.x version number.

3. Check for incompatible plugins

Even though you removed sanity-plugin-media, other plugins may be incompatible. The "palette" property is related to image metadata, so any plugin touching images or assets needs to be v2-compatible. Look through your package.json for other plugins and verify they support Studio v2.

4. Verify your schema preview configurations

If you have custom preview configurations in your schemas, especially for documents with images, make sure they're using the correct v2 syntax for accessing image fields.

Important context: Studio v2 reached end-of-life on December 7, 2023, meaning it no longer receives security updates or bug fixes. If you're working on an active project, I'd strongly recommend migrating to Studio v3 instead of troubleshooting v2 further. V3 has better stability, modern tooling, and ongoing support.

If you share the stack trace you mentioned, I can provide more specific guidance - look particularly for which component or file is trying to access the palette property.

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)

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' }
        }
      ]
    }
  ]
};
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 🙂
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 🙂
I think I know why this is happening and where the bug lives 👀 Will take a look tomorrow 🕵️‍♀️
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?
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' }
        },
        
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!
Awesome! Happy to hear it’s working 🥳

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?