Possible bug when hiding trace then replotting

I have encountered this error: Uncaught TypeError: Cannot read property ‘uid’ of undefined
It happens when I hide one of the traces on my plot by clicking it on the legend and then trying to do a Plotly.react which may remove the hidden trace from the traces array.
The only way I can find to fix it is to purge the plot before updating the traces array.
This error still appears if I turn the trace back on via the legend before the Plotly.react is triggered.
Can anyone please advise?

Update, it appears it’s only Plotly.react that has this issue. Plotly.newPlot without doing a purge first seems to be ok.

Thanks for the report!

Could you provide a reproducible example to help us debug?

I am also encountering this bug. I have implemented continuous error shading (as demonstrated here: https://plot.ly/javascript/continuous-error-bars/), and have made the shading toggle-able by a button on the plot. I am also using jquery to update the plot and fetch new data from a database when different options are chosen (the selection menus are not part of the plot, I built them manually elsewhere on the webpage).

When I make the shading visible, and deselect one of the traces (and its shaded error) by clicking in the legend, and then choose another option for the plot, causing it to reload data and call “react”, I get the same error. Also resolved by using “newPlot”, which I’d prefer not to do. Any ideas?

Sorry for the delayed reply.
It’s not very easy to pick it all apart. I can send you the whole folder in a zip file if you like?

We would prefer a reproducible example isolated in a Codepen.

But if you can’t, a zip will do.

My first codepen: https://codepen.io/gemma-nash/pen/xMEyGg ! Hope it helps…
Click to hide a couple of traces, then change the select lists so that at least two of the selects have options other than ‘all’.

@etienne have you had chance to look into this one? Sorry to keep bothering you.

I am getting the same error; the Codepen provided by @gnasher reproduces it well. Looks like it’s happening in getTraceIndexFromUid as the plot is trying to id and remove existing traces, and it’s missing a null check for traces that have been hidden.

This problem should be fixed in plotly.js v1.44.4

Awesome! Can confirm that I am no longer seeing the issue in v1.44.4. Thanks @etienne!