Skip to content

Render fails on textTruncation when the node's font is not yet loaded #343

Description

@nathanacurtis

A render can fail outright with:

Error: Render failed: in set_textTruncation: Cannot write to node with unloaded font
"Centra No2 Book". Please call figma.loadFontAsync({ family: "Centra No2", style: "Book" })
and await the returned promise first.

Three components failed this way in one catalogue sweep — a select input, a payment card input, and a search bar. Re-rendering the same components minutes later succeeded, so the failure depends on whether the font happens to be loaded already, not on the spec.

Why it is intermittent

Figma requires a node's current font to be loaded before any text property is written, textTruncation included. Once a font has been loaded in a session it stays loaded, so whichever component renders first in a fresh Figma session pays the cost — and fails, while everything after it succeeds.

That makes this worse than its frequency suggests: it fails a first render, which is exactly the run a new user makes.

Where

Styles.applyKey, the textOverflow case, writes textTruncation directly. DimensionStyle.applyWidthHeight already faces the same rule for TEXT nodes and calls ensureCurrentFontLoaded(text) defensively before touching textAutoResize. The textOverflow path has no equivalent guard, and maxLines sets textAutoResize/textTruncation too.

Loading the node's current font before writing either property should close it — the helper already exists and is cheap once warm.

Reproducing

Restart Figma so no fonts are loaded, then render a component whose text elements declare textOverflow or maxLines.

Metadata

Metadata

Assignees

Type

No type

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions