Hi everyone,
I'm developing a Figma plugin that clones a bar chart component and updates each bar's label dynamically. However, I'm facing two main issues:
- "table index is out of bounds" error (WebAssembly crash) when modifying cloned instances.
- Font loading issues when setting
.characters
on text nodes inside each bar.
How My Plugin Works
- The user selects a chart component (which contains multiple "Bar Elements").
- The plugin clones the selected instance and adjusts bar heights.
- Each "Bar Element" contains a label text node inside a "Label Frame".
- I need to load the font before modifying the label text.

What I’ve Tried So Far
- Checked if nodes exist before modifying them.
- Ensured
figma.loadFontAsync()
runs before updating.characters
. - Wrapped
barElement.clone()
intry...catch
to prevent crashes. - Checked
fontName
before callingloadFontAsync()
. - Tried moving
figma.loadFontAsync()
outside thefor
loop to load it once before modifying text.
Despite these fixes, I still get "table index is out of bounds" errors, but the plugin works good and modifying text nodes as needed, the problem is the errors in the console.

Questions for the Community
- Why is
figma.loadFontAsync()
still causing errors, even when awaited properly? - Could there be an issue with how I’m cloning instances inside a detached parent?
- Is there a better way to safely modify text in cloned instances?
Would love any insights! Thanks in advance.