Getting error "figma_app.min.js.br:5 Error: in set_selection: The node with id "368:20" does not exist"

Been searching online and not able to hunt down the reason or solution for this error? Anyone can help. Here is my code:

 figma
            .createImageAsync(prop.url)
            .then(async (image: Image) => {
                const { width, height } = await image.getSizeAsync()
                rect.resize(width, height)

                // Set the fill on the rect
                rect.fills = [
                    {
                        type: 'IMAGE',
                        imageHash: image.hash,
                        scaleMode: 'FILL'
                    }
                ]

                //send message to ui to change button label
                console.log('IMAGE MADE!!')

                figma.ui.postMessage({
                    type: 'image-made',
                    message: 'Make another'
                })

The image does get rendered to the canvas and everything else seems to work fine.

I think I solved it. I was creating the rectangle for the fill outside of the promise. I added it within the promise and it seems to have cleared the error. My thought is the rectangle was getting created once and by moving it into the promise, it is getting created each time the promise is fired. Now there is a node for the fill for the second render - this makes sense since I was only getting this error on the second fill event.

1 Like