🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Discussion about hanging export command in Sanity CLI with possible solution

34 replies
Last updated: Apr 6, 2021
Hi chaps, is it normal that
npx sanity dataset export <mydatasetname> --raw - >file.tar.gz
should run forever, hanging (bizarrely) on the
Adding assets to archive...
step?
Apr 6, 2021, 3:29 PM
What document statistics are you working with? You can find that at manage.sanity.io .
Apr 6, 2021, 3:39 PM
I’m not sure what that means. How many documents?
Apr 6, 2021, 3:48 PM
Hi
user T
, sorry you're running into trouble exporting your dataset. It's indeed odd that it shows the assets step when using the
--raw
or
--no-assets
flags.
Could you check if this works when entered directly in the CLI (i.e. not via a script) from your project's studio root folder?

sanity dataset export development development.tar.gz --raw
Also, could you DM me your project ID?
Apr 6, 2021, 3:49 PM
FWIW I just tried again without
--raw
etc, and it works:
? File "/tmp/foo.tar.gz" already exists, would you like to overwrite it? Yes
Exporting dataset "development" to "/tmp/foo.tar.gz"
✔ Exporting documents... (2824/2824)
✔ Downloading assets... (1721/1721)
✔ Adding assets to archive...
✔ Clearing temporary files...
Export finished (4m 29s)
Apr 6, 2021, 3:49 PM
user M
that’s exactly how i’m running it
Apr 6, 2021, 3:49 PM
this worked:
npx sanity dataset export development --asset-concurrency 20 /tmp/foo.tar.gz
Apr 6, 2021, 3:49 PM
(but with all the assets)
Apr 6, 2021, 3:50 PM
Thanks for any help btw 🙂
Apr 6, 2021, 3:50 PM
@sanity/cli version 2.7.4
if that helps
Apr 6, 2021, 3:50 PM
That's helpful context, thanks. In that case you could skip my first question above - we'll see if we can spot any errors using the project ID you just shared 🙂
Apr 6, 2021, 3:51 PM
thank you!
Apr 6, 2021, 3:52 PM
BTW I’m pretty new to Sanity, so unsure whether it’s just operator error on my part.
Apr 6, 2021, 3:53 PM
Hey, even weirder…
Apr 6, 2021, 3:54 PM
Doesn't look like it. From what I can tell, you're using the command and flags correctly. Hope the logs give a hint here 🙂
Apr 6, 2021, 3:54 PM
I just tried it again
Apr 6, 2021, 3:54 PM
npx sanity dataset export development /tmp/foo2.tar.gz --raw
Apr 6, 2021, 3:54 PM
and it ran to completion super fast
Apr 6, 2021, 3:55 PM
maybe it’s an API issue and the cli output was a redherring?
Apr 6, 2021, 3:55 PM
? File "/tmp/foo2.tar.gz" already exists, would you like to overwrite it? Yes
Exporting dataset "development" to "/tmp/foo2.tar.gz"
✔ Exporting documents... (4545/4545)
✔ Downloading assets...
✔ Adding assets to archive...
✔ Clearing temporary files...
Export finished (3.7s)
Apr 6, 2021, 3:55 PM
or maybe having done a full export with assets before, made some difference to doing a raw export after?
Apr 6, 2021, 3:55 PM
i’m struggling to see what else changed.
Apr 6, 2021, 3:55 PM
Did you always place the
--raw
flag at the end? I think there's a known issue when it's placed earlier in the command and not correctly picked up.
Apr 6, 2021, 3:56 PM
I experimented with it before and after the filepath
Apr 6, 2021, 3:57 PM
Perhaps that’s the difference
Apr 6, 2021, 3:57 PM
Are we really hitting bugs due to brittle/fragile commandline option parsing in 2021? 😉
Apr 6, 2021, 3:58 PM
(I mean, good to know, and I’ll keep it in mind to avoid it, so thank you, but also…wow?)
Apr 6, 2021, 3:58 PM
Sorry, that sounds a bit ungrateful of me. I am very grateful if this is in fact the answer.
Apr 6, 2021, 4:00 PM
user M
do you see anything interesting in the logs?
Apr 6, 2021, 4:01 PM
It's worth verifying on our end as well that this is indeed the issue, but I do recall seeing it pop up recently. Bugs are of all the ages I guess 😉 You should feel confident to place flags arbitrarily everywhere else though.
I'll keep you posted on this one but recommend placing it deliberately at the end for now unless that continues to give throw errors.
Apr 6, 2021, 4:01 PM
I’m happy to write this off as “CLI parsing is fragile, ensure we build command line correctly” if you think that’s the issue.
Apr 6, 2021, 4:01 PM
sure, i’ll note that.
Apr 6, 2021, 4:01 PM
thanks very much!
Apr 6, 2021, 4:02 PM
between you and me, i like the old bugs the best 😉
Apr 6, 2021, 4:02 PM
Thanks
user A
and
user M
for all your help! Hopefully all queries in the future will be this simple.
Apr 6, 2021, 4:06 PM

Sanity– build remarkable experiences at scale

Sanity is a modern 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?