Skip to content

Plugin freezes on theme switch when components are inside Figma Slots #3838

@UdayHyma

Description

@UdayHyma

Description
The Plugin crashes/freezes when switching themes on components placed inside Figma Slots. The console error is:
getSharedPluginDataKeys: The node (instance sublayer or table cell) with id
"I2159:13129;2156:6333;2156:3693;..." does not exist
The Plugin enters a permanent "Hold on, updating..." state and must be restarted. Reported customer (Florian Gampert) is restarting 30-40 times/day.

Root Cause
PR #3816 ("feat: add SlotNode support for Figma Slots", merged Mar 27) added SLOT to ValidNodeTypes and added traversal handling in applySiblingStyle.ts, but did not add error handling for stale compound node IDs.

Most likely crash path (confirmed from code analysis, but exact entry point should be verified with a debugger — there may be other traversal paths that also hit getSharedPluginDataKeys):

applySiblingStyle.ts → recursively traverses node.children including SLOT nodes
For each child → SharedDataHandler.keys(node) → calls node.getSharedPluginDataKeys(namespace)
Instance sublayers inside Slots have compound IDs (semicolon-separated paths like I2159:13129;2156:6333;...)
When a theme change alters the Slot's internal component structure, these compound IDs become stale
Figma API throws: "The node... does not exist"
No try-catch wraps this call → unhandled error → Plugin hangs

Key files:

packages/tokens-studio-for-figma/src/plugin/asyncMessageHandlers/applySiblingStyle.ts — recursive traversal with case 'SLOT'
packages/tokens-studio-for-figma/src/plugin/SharedDataHandler.ts — keys() method calls getSharedPluginDataKeys without try-catch
packages/tokens-studio-for-figma/src/constants/ValidNodeTypes.ts — includes 'SLOT' with type cast

Reproduction Steps

Open Figma with Plugin V2.11.4
Create a component with tokens applied (e.g., using a light theme)
Place the component inside a Figma Slot within another component/frame
Open the Plugin, confirm tokens are visible on the component
Select the component inside the Slot
Switch themes (e.g., light → dark)

Expected: Theme applies, token values update
Actual: "No tokens found" appears → Plugin enters "Hold on, updating..." state → console shows getSharedPluginDataKeys error on stale compound node ID

Related

PR #3816: feat: add SlotNode support for Figma Slots

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

Status

📥 Triage

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions