mikaelvesavuori / figmagic

Figmagic is the missing piece between DevOps and design: Generate design tokens, export graphics, and extract design token-driven React components from your Figma documents.
https://docs.figmagic.com
MIT License
807 stars 71 forks source link

Syncing graphics fails when there are too many images #167

Closed rwproctor closed 2 years ago

rwproctor commented 2 years ago

We have a graphics page that contains a large number of icon components. When we go to sync our icons, we are getting the following error...

Error: Error: Error: Missing one or more of required arguments: "figmaToken", "figmaUrl" when attempting to get data from Figma API!

This is not the actual error however, the real issue is the request to fetch all the icons is maxing out the Figma API. When I dump out the actual error this becomes clear. Note the status code is a 413. If I reduce the number of graphics the export works fine.

image

Better error handling here would provide more meaningful information to the end user and in the case where there are just too many graphics, maybe put out a message to that effect. Is there a suggested workaround or is there a limit to how many graphics can be exported?

Thanks,

mikaelvesavuori commented 2 years ago

Hi!

Improving that catch-all error message is a good idea. I'm releasing this in version 4.5.3 shortly. TBH I don't really know of a proper solution to this issue as it's technically outside of what I can do much about. Also, I don't have any idea about the max cap used by Figma. Googling doesn't give me anything substantial to go on...

However I have an idea that might be functional as a workaround.

Since Figmagic can run with both "direct" commands and with configuration files, it should be possible to split the icons into one or more additional files with just a Graphics page each. Then you could set up a command or script that sequentially runs Figmagic multiple times (collecting all the graphics from each file) with something along the lines of figmagic --syncGraphics --outputFolderGraphics <somethingDifferentPerRun> effectively ensuring you don't overwrite them for each run. Then add them all together by moving all the folders generated into one and the same.

It's not beautiful but it should be workable. The scripting shouldn't be the hard part, but rather having to deal with splitting it across more files.

That's the best I can figure out on a Friday night.

mikaelvesavuori commented 2 years ago

4.5.3 is out. See https://github.com/mikaelvesavuori/figmagic/releases/tag/v4.5.3

rwproctor commented 2 years ago

Thanks for the suggested workaround! My first route is going to try to bring down the number of icons. We brought in a large library which we probably don't need many of the icons. Thanks for the quick update to 4.5.3. Much better now ;^)

image