I’m working on a Figma plugin that generates text styles based on design tokens. Everything works fine until I try to load a custom font using figma.loadFontAsync(). The promise seems to hang and never resolves or throws an error.
Here’s my current implementation:
async function generateTextStyle(designToken) {
const textStyle = figma.createTextStyle();
// Load default Roboto font first
await figma.loadFontAsync(textStyle.fontName);
// This line causes the function to hang
await figma.loadFontAsync({
family: 'Inter',
style: 'Medium',
});
// Configure text style properties
textStyle.fontName = {
family: 'Inter',
style: 'Medium',
};
textStyle.name = designToken.label;
textStyle.fontSize = designToken.size;
textStyle.lineHeight = { value: designToken.leading, unit: 'PIXELS' };
}
The font loading promise never completes. What could be causing this behavior? Is there a specific way to handle custom fonts in Figma plugins?
The hanging usually comes from loading the default font when you don’t need to. Drop that first loadFontAsync call for textStyle.fontName - you haven’t set it to Inter yet, so it’s trying to load whatever system default is there. Also check that Inter Medium is actually in your Figma workspace. Font weights sometimes get renamed when you upload them to Figma, so Medium might show up as something different. Quick test: manually create a text node with Inter and see what style names pop up. And throw a timeout wrapper around those font loading calls so your plugin doesn’t hang forever if things break.
first, make sure inter medium is actually installed in your figma account. sometimes the font family exists but not that specific weight. run figma.listAvailableFontsAsync() to see what’s actually available before you try loading it.
Had the same problem! The font variant names have to match exactly what Figma sees. Try ‘Regular’ instead of ‘Medium’ for Inter, or just check what style names are actually available in your workspace first. I also wrapped the font loading in a try-catch block - that fixed the hanging when fonts aren’t available. Figma just fails silently when it can’t find the font style you want, so you need proper error handling.
i struggled with this too! make sure the font you’re loading is actually available in your figma. also, just use the loadFontAsync for the font you want to assign directly, no need for the earlier call. hope this helps!
This is probably a timing issue with your font loading sequence. When you create a text style with figma.createTextStyle(), it defaults to Roboto Regular. Then you’re immediately trying to load that default font before switching to Inter - this creates a race condition that causes the hanging.
Skip loading the default font entirely and go straight to your target font. Also, font loading can fail silently if the font isn’t installed in your Figma workspace or there’s a network issue.
I’ve found that adding a timeout mechanism around the font loading promise prevents indefinite hanging. Use Promise.race() with a timeout promise so your plugin doesn’t freeze when fonts fail to load.
This is exactly why I switched to automation for font loading. Dealt with the same nightmare managing design systems.
The issue isn’t just Figma - it’s that you’re doing this manually every time. figma.loadFontAsync is buggy and unreliable. Stop wrestling with it and automate the whole design token pipeline instead.
My automated flows:
- Check if fonts exist before loading
- Handle loading with fallbacks
- Process all tokens in batches
- Retry failures automatically
- Keep everything synced across tools
Skip the plugin debugging completely. Let automation handle validation, loading, and error recovery while you do actual work.
I’ve run this on design systems with hundreds of text styles - works perfectly. No hanging promises, no manual fixes.
Latenode’s great for building these workflows: https://latenode.com