Timeout error when exporting dataset, investigation ongoing.
This is a known issue with the @sanity/export package when dealing with datasets that have a large number of assets. The error you're seeing isn't actually about the 180-second timeout being too short – it's about the way the export tool handles concurrent asset downloads.
The MaxListenersExceededWarning messages are the key clue here. The export tool is trying to download many assets simultaneously, which creates too many event listeners and eventually causes the socket connection to hang while "Adding assets to archive", triggering the timeout error.
Here are several solutions you can try:
1. Export without assets first (quickest workaround)
If you primarily need the document data and can handle assets separately:
sanity dataset export production production-docs-only.ndjson --no-assets2. Update your Sanity CLI
Make sure you're running the latest version of the Sanity CLI, as there have been improvements to the export functionality:
npm install -g @sanity/cli@latest3. Adjust Node.js memory and event emitter limits
You can increase Node.js limits when running the export:
NODE_OPTIONS="--max-old-space-size=4096" sanity dataset export production production.tar.gz4. Export during off-peak hours
Network conditions and API load can affect asset downloads. Try running the export during off-peak hours when there's less network congestion.
5. Contact Sanity support for large datasets
If you have a particularly large number of assets (like your 447 assets), the Sanity documentation notes that you may want to contact support for assistance with large dataset exports.
6. Export documents and assets separately
You could also manually download assets using the Export API with custom pagination logic to avoid overwhelming the connection.
The fact that this worked before but doesn't now suggests either the number of assets has grown, or there may have been network/infrastructure changes. The export tool's concurrent download mechanism can be fragile with larger asset collections, which is why the --no-assets flag is often the most reliable workaround for immediate needs.
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.