figma-plugin icon indicating copy to clipboard operation
figma-plugin copied to clipboard

Out of memory error, when renaming token group in large document

Open thomasaull opened this issue 3 months ago • 0 comments

Describe the bug

I have a document with many nodes (not sure how many, the plugin sometimes reports 20k sometimes 120k when doing a batch operation) spread across ~30 pages. Tokens are used basically everywhere, only via the plugin, we don’t use the export to styles/variables currently. We want to rename a token group from colors to color but we run in an out of memory error. When monitoring memory usage the amount of allocated memory increases to about 5 GB before the error. The memory is also not released until I close the tab or navigate somewhere else.

To Reproduce Steps to reproduce the behavior:

  1. Open tokens.studio plugin
  2. Rename group colors to color
  3. Click "Change" after a couple of seconds the "Remap all tokens that use tokens in colors. group?"
  4. Select "Dokument" and click "Yes"
  5. Wait for the page to become unresponsive, eventually the Figma out of memory appears

I found this PR from copilot: https://github.com/tokens-studio/figma-plugin/pull/3526 and a quick code search revealed that the same logic is used in many places. Maybe a batched operation would solve this and other issues with large document and/or token sets.

Further tests revealed that renaming a single token of the group actually works.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots or Screencasts If applicable, add screenshots to help explain your problem.

Figma file (optional) Unfortunately I can’t share the document or the tokens set :-/

JSON (optional) If possible, attach the JSON that leads to this bug.

thomasaull avatar Sep 29 '25 12:09 thomasaull