Error with custom document actions in Sanity Studio

11 replies
Last updated: Feb 16, 2022
Looking to add custom document actions. This was working last week, but now I'm getting an undefined error (in thread) when clicking the "more" button next to Publish, even with a basic "Hello Word" custom action. resolver code inside thread as well
Feb 9, 2022, 2:15 AM
The Desk tool crashedAn uncaught exception in the 
Desk tool caused the Studio to crash.
TypeError: Cannot read properties of undefined (reading 'replace')
    at ActionMenuListItem (/static/js/app.bundle.js:495455:55)
    at renderWithHooks (/static/js/vendor.bundle.js:18134:18)
    at mountIndeterminateComponent (/static/js/vendor.bundle.js:20813:13)
    at beginWork (/static/js/vendor.bundle.js:21927:16)
    at HTMLUnknownElement.callCallback (/static/js/vendor.bundle.js:3519:14)
    at Object.invokeGuardedCallbackDev (/static/js/vendor.bundle.js:3568:16)
    at invokeGuardedCallback (/static/js/vendor.bundle.js:3623:31)
    at beginWork$1 (/static/js/vendor.bundle.js:26534:7)
    at performUnitOfWork (/static/js/vendor.bundle.js:25485:12)
    at workLoopSync (/static/js/vendor.bundle.js:25461:22)
Feb 9, 2022, 2:15 AM
export default function resolveDocumentActions(props: any) {
  if (props.type === "newsletter") {
    return [...defaultResolve(props), TestNewsletterAction];

  return defaultResolve(props);
Feb 9, 2022, 2:15 AM
doesn't matter what the custom action is, I get the error
Feb 9, 2022, 2:16 AM
@sanity/cli 2.21.5 (latest: 2.27.0)@sanity/base 2.24.0 (latest: 2.27.0)
@sanity/cli 2.24.0 (latest: 2.27.0)
@sanity/components 2.2.6 (latest: 2.14.0)
@sanity/core 2.24.0 (latest: 2.27.0)
@sanity/dashboard 2.24.0 (latest: 2.27.0)
@sanity/default-layout 2.24.0 (latest: 2.27.0)
@sanity/default-login 2.24.0 (latest: 2.27.0)
@sanity/desk-tool 2.24.0 (latest: 2.27.0)
@sanity/production-preview 2.2.6 (latest: 2.15.0)
@sanity/vision 2.24.0 (latest: 2.27.0)
Feb 10, 2022, 1:43 AM
user E
Feb 10, 2022, 1:44 AM
Thanks Andrew. Are you able to update Sanity Studio, to check if this problem is still happening on the latest version?
You can do that by running the
sanity upgrade
CLI command.
Feb 10, 2022, 9:33 AM
user E
this doesn't solve the issue 😞
Feb 11, 2022, 7:06 PM
it looks like this is due to me making the custom document action an async function
Feb 11, 2022, 7:55 PM
not sure why it was working before and suddenly stopped
Feb 11, 2022, 7:56 PM
but I rewrote it to use react useState and useEffect to get my inital state
Feb 11, 2022, 7:57 PM
Ah, great! I'm glad you got it working 🙌.
Feb 16, 2022, 11:06 AM

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?