Sanity commit error "e is not a function" when creating documents with Spaces

10 replies
Last updated: Sep 30, 2021
Hello, I am getting this error in the latest version of sanity:An error occurred during commit: e is not a function.

This happens every time I try to create any new document. Worth noting I am using the experimental feature Spaces. I wonder if anyone else is having this issue?
AI Update

I can see you're hitting a frustrating error that's blocking document creation! The "An error occurred during commit: e is not a function" message is a minified JavaScript error that needs some investigation.

First, regarding "Spaces" - I couldn't find this in the public Sanity documentation, but that doesn't mean it doesn't exist. Since you mentioned it's an experimental feature, it could be:

  • A private beta feature not yet publicly documented
  • Part of a plugin you're using
  • Something referred to internally by a different name in the docs

If you have access to any documentation or setup instructions for Spaces, those might have specific troubleshooting steps. You might also want to clarify with whoever enabled this experimental feature for you whether there are known issues.

Get the Full Error Details

The "e is not a function" message is from minified code and doesn't tell us much. Open your browser's developer console (F12, or right-click → Inspect → Console tab), then try creating a document again. Look for the full error stack trace - it should show which function is failing and where. This is crucial for diagnosing the root cause.

Quick Fixes to Try

1. Update to the latest version:

npm update sanity @sanity/ui @sanity/vision
npm install

This error could already be fixed in a newer version.

2. Clear cache and rebuild:

rm -rf node_modules .sanity
npm install

3. Check for version conflicts:

npm ls sanity

Look for duplicate versions of the sanity package - this commonly causes "function not defined" errors.

Verify Your Environment

Check your Node.js version:

node --version
  • Studio v3 requires Node.js 18+
  • Studio v4 requires Node.js 20+

If you're on an older version, upgrade Node and reinstall dependencies.

Investigate Configuration Issues

Since you're using an experimental feature, there could be a configuration conflict. Try:

  1. Comment out custom document actions in your schema temporarily
  2. Disable custom plugins one by one to isolate the issue
  3. Check for schema validation functions that might be throwing errors instead of returning values
  4. Look for async functions that aren't properly awaited in custom components

Common Causes of Commit Errors

This type of error during commits often stems from:

  • Custom document actions with incorrect function signatures
  • Plugins that aren't compatible with your Studio version
  • Schema validation functions that throw errors
  • Experimental features interacting unexpectedly with custom code

Report to the Sanity Team

Since this blocks document creation entirely and involves an experimental feature, please report it with:

  • Your exact sanity package version (from package.json)
  • Node.js version
  • The complete error stack trace from the browser console (critical!)
  • Your configuration setup
  • Any details about how Spaces was enabled
  • Steps to reproduce

Report in the Sanity Community Slack #help channel or file a GitHub issue. If Spaces is a private beta feature, you may also have a dedicated support channel.

Has anyone else encountered this specific error, especially with experimental features? Please share your error details and version info!

Show original thread
10 replies
Hi
user M
, no there are no additional logs or errors in the console. There does appear to be a GET request in the network tab but that returns a 200 response so that seems fine.
Hi
user M
, no there are no additional logs or errors in the console. There does appear to be a GET request in the network tab but that returns a 200 response so that seems fine.
user M
, This issue is still occurring. I’d like to try and roll back my sanity version to see if I can get it going. I can only see
sanity upgrade
as an option in the cli. Is there a recommended method for downgrading?
Before rolling back, can you try deleting node_modules, then reinstalling?
Sure, good idea actually…
I think I did something weird where I installed sanity cli locally as opposed to globally.
this will get you a global install:
npm install -g @sanity/cli
user M
you’re my hero 🙌 right before this weeks WIP too.
Hahaha, very happy to help!
Hahaha, very happy to help!

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?