JupyterLab: "Javscript Error: Cannot set properties of null"

I’m noticing a funny interaction between Plotly and a version of Jupyter Lab. Instead of giving me a 3D surface plot , I get a blank 3D block and an error message that reads: “Javascript Error: Cannot set properties of null (setting '0')”.

Code that runs fine in Jupyter Notebook, such as the official 3d surface plot documentation, or the following small example, produce the error in Jupyter lab:

import torch 
import plotly.graph_objects as go

zz = torch.rand(33,33)
x = torch.linspace(0, 1, steps=zz.shape[-2]).numpy()
y = torch.linspace(0, 1, steps=zz.shape[-1]).numpy()

fig = go.Figure(data=[go.Surface(z=zz.cpu().numpy(), x=x, y=y)])

So, the expected result is what I see when I run in jupyter notebook (not lab) or raw python script:

But instead what I see in JupyterLab is this:

Since this code works fine in regular python or Jupyter notebook, I’m pursuing this problem on both Plotly and Jupyter forums to see if anyone can suggest a fix. So far I’ve only found one instance of a similar problem reported on the web but there were no replies to the question.

Any idea? Thanks.

To be clear: I don’t believe this is a plotly bug or a jupyter bug, just some weird problem with one particular server installation. Happens for multiple versions of Plotly and multiple versions of Jupyter, and on multiple browsers.

Update: This seems to affect only Surface plots! I can do 3D Scatter plots just fine! ? (but I want a surface plot)