Discussion about hanging export command in Sanity CLI with possible solution
34 replies
Last updated: Apr 6, 2021
J
Hi chaps, is it normal that should run forever, hanging (bizarrely) on the
npx sanity dataset export <mydatasetname> --raw - >file.tar.gz
Adding assets to archive...step?
Apr 6, 2021, 3:29 PM
G
What document statistics are you working with? You can find that at manage.sanity.io .
Apr 6, 2021, 3:39 PM
J
I’m not sure what that means. How many documents?
Apr 6, 2021, 3:48 PM
P
Hi
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?
Also, could you DM me your project ID?
user T
, sorry you're running into trouble exporting your dataset. It's indeed odd that it shows the assets step when using the --rawor
--no-assetsflags.
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
Apr 6, 2021, 3:49 PM
J
FWIW I just tried again without
--rawetc, 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
J
user M
that’s exactly how i’m running itApr 6, 2021, 3:49 PM
J
this worked:
npx sanity dataset export development --asset-concurrency 20 /tmp/foo.tar.gz
Apr 6, 2021, 3:49 PM
J
(but with all the assets)
Apr 6, 2021, 3:50 PM
J
Thanks for any help btw 🙂
Apr 6, 2021, 3:50 PM
J
@sanity/cli version 2.7.4if that helps
Apr 6, 2021, 3:50 PM
P
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
J
thank you!
Apr 6, 2021, 3:52 PM
J
BTW I’m pretty new to Sanity, so unsure whether it’s just operator error on my part.
Apr 6, 2021, 3:53 PM
J
Hey, even weirder…
Apr 6, 2021, 3:54 PM
P
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
J
I just tried it again
Apr 6, 2021, 3:54 PM
J
npx sanity dataset export development /tmp/foo2.tar.gz --raw
Apr 6, 2021, 3:54 PM
J
and it ran to completion super fast
Apr 6, 2021, 3:55 PM
J
maybe it’s an API issue and the cli output was a redherring?
Apr 6, 2021, 3:55 PM
J
? 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
J
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
J
i’m struggling to see what else changed.
Apr 6, 2021, 3:55 PM
P
Did you always place the
--rawflag 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
J
I experimented with it before and after the filepath
Apr 6, 2021, 3:57 PM
J
Perhaps that’s the difference
Apr 6, 2021, 3:57 PM
J
Are we really hitting bugs due to brittle/fragile commandline option parsing in 2021? 😉
Apr 6, 2021, 3:58 PM
J
(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
J
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
J
user M
do you see anything interesting in the logs?Apr 6, 2021, 4:01 PM
P
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.
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
J
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
J
sure, i’ll note that.
Apr 6, 2021, 4:01 PM
J
thanks very much!
Apr 6, 2021, 4:02 PM
J
between you and me, i like the old bugs the best 😉
Apr 6, 2021, 4:02 PM
J
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.