Possible EventEmitter memory leak detected during dataset export, JSON termination error, bug identified and fixed in new release.
This error occurs when the sanity dataset export command encounters a corrupted or truncated JSON response from the Sanity API. The "Unexpected end of JSON input" shows that a document (in your case, a mux.videoAsset document) was cut off mid-stream during export.
Good news: This was a known bug that has been fixed!
According to this community answer, this exact issue was identified and resolved in Sanity CLI version 1.149.17 (released June 2020). The fix not only resolved the error but also significantly improved export performance.
Quick Solutions
1. Update your Sanity CLI (most important):
npm install -g @sanity/cli@latestThis should resolve the issue entirely. After updating, try your export again.
2. Export without assets (temporary workaround):
sanity dataset export dev --no-assets dev-documents-only.tar.gzAs you discovered, the --no-assets flag works because the issue typically occurs when streaming large asset data. This exports only your documents and skips asset files.
3. Use --no-compress (if you need assets):
sanity dataset export dev --no-compressThis can sometimes help with streaming issues.
About the MaxListenersExceededWarning
The MaxListenersExceededWarning you're seeing indicates the export process is creating many simultaneous connections. While this warning itself isn't fatal, it's a symptom of the underlying bug that was causing the JSON parsing failure.
If Problems Persist After Updating
- Check your Sanity CLI version with
sanity versions - Try exporting during off-peak hours when API load is lower
- For very large datasets on Enterprise plans, consider using Cloud Clone which duplicates datasets server-side
- Contact Sanity support if you continue experiencing issues
The export file that was created is likely incomplete and shouldn't be used for restoration without verification.
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.